Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to adjust border radius to match parent border radius

I want to have a text box with a line on the left side for design purpouses. The box has a border radius oh 10px. The problem is that the line is too thick if I make it 10px wide. So I made it 5px and tried to adjust the horizontal and vertical radiuses separately to make it match the border of the box. I have tried for ages and I just cant get it right. Here’s my best attempt:

div {
  position: relative;
  width: 400px;
  height: 200px;
  background-color: rgba(0, 255, 50, 0.3);
  border-radius: 10px;
}

div::before {
  content: "";
  position: absolute;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
  left: 0;
  width: 5px;
  height: calc(100% - 3px);
  background-color: rgba(0, 150, 0, 0.5);
  border-radius: 5px 0 0 5px / 10px 0 0 10px;
}

p {
  position: absolute;
  top: 40%;
  left: 35%;
}
<div>
  <p>Make me beautiful!</p>
</div>

Is it even possible to make this work and how?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Edit: I’m using the same variable for the background color of the line and the box. Then I’m applying a filter to the line to make it darker.

>Solution :

If it’s only for decoration, use a gradient:

div {
  position: relative;
  width: 400px;
  height: 200px;
  background: 
   linear-gradient(rgba(0, 150, 0, 0.5) 0 0) /* color */
     left / 5px 100% no-repeat, /* position / width height */
   rgba(0, 255, 50, 0.3);
  border-radius: 10px;
}

p {
  position: absolute;
  top: 40%;
  left: 35%;
}
<div>
  <p>Make me beautiful!</p>
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading