Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css border radius on unknown element size

Tags:

css

If I set border-radius: 100000px on an element it will a perfect radius. If I set border-radius: 100% I get a completely different result.

.test {
  background: red;
  width: 150px;
  height: 50px;
}

.border1 {
  border-radius: 10000px;
}

.border2 {
  border-radius: 100%;
}
Correct
<div class="test border1"></div><br>
Weird
<div class="test border2"></div>

Is there a way to use another unit to get the same result as 10000px? My element size might be unknown.

like image 416
Jens Törnell Avatar asked Jan 02 '18 07:01

Jens Törnell


Video Answer


2 Answers

You can use vh length unit for same result

.border2 {
  border-radius: 100vh;
}
like image 182
Cenk YAGMUR Avatar answered Nov 27 '22 18:11

Cenk YAGMUR


Correctly said Cenk YAGMUR but more than 50% of the height does not take border-radus. border-radius is more than 50% of the minimum (width, height) meaningless.

.border2 {
  border-radius: 50vh;
}
like image 25
Raz Galstyan Avatar answered Nov 27 '22 17:11

Raz Galstyan