Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curved end of border-bottom in CSS

Tags:

html

css

I'm trying to make my border bottom look like this:

enter image description here

With one curved end. Currently it looks like this:

enter image description here

The CSS I'm trying to use is border-bottom-right-radius: 10px;. The code looks like this:

<div class="title">
    lorem ipsum
</div>

.title {
    border-bottom: 10px solid $mainRed;
    border-bottom-right-radius: 10px;
}

I also tried border-radius: 10px; which gives me the same result except both ends are curved. Increasing this number just makes the line slope upwards. How can I make the line look correct?

like image 298
Virge Assault Avatar asked Dec 10 '15 21:12

Virge Assault


People also ask

How do you curve the bottom of a border in CSS?

CSS Syntaxborder-bottom-left-radius: length|% [length|%]|initial|inherit; Note: If you set two values, the first one is for the bottom border, and the second one for the left border. If the second value is omitted, it is copied from the first. If either length is zero, the corner is square, not rounded.

How do you defines the shape of the border of the bottom left corner?

The border-bottom-left-radius CSS property rounds the bottom-left corner of an element by specifying the radius (or the radius of the semi-major and semi-minor axes) of the ellipse defining the curvature of the corner.

What is Border end end radius?

The border-end-end-radius CSS property defines a logical border radius on an element, which maps to a physical border radius that depends on the element's writing-mode , direction , and text-orientation . This is useful when building styles to work regardless of the text orientation and writing mode.

Which CSS property is used to make the rounded borders?

The border-radius CSS property rounds the corners of an element's outer border edge.


2 Answers

This is not possible within default borders, as border-radius controls the radius around the element, not a single border edge.

I would recommend faking it with a pseudo-element:

div {
  max-width:50vw;
  padding-bottom:25px;
  position:relative;
}
div:after {
  content:'';
  position:absolute;
  bottom:0;
  left:0;
  right:0;
  background:red;
  height:20px;
  border-radius:0 10px 10px 0;
}
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quippe: habes enim a rhetoribus; Quodsi ipsam honestatem undique pertectam atque absolutam. Duo Reges: constructio interrete. Urgent tamen et nihil remittunt.</div>
like image 174
Niels Keurentjes Avatar answered Oct 14 '22 12:10

Niels Keurentjes


I dont know if this is the best solution, but there it go:

<style>
.title .underline {
    border-top: 10px solid red;
    border-top-right-radius: 10px;
    border-bottom: 10px solid red;
    border-bottom-right-radius: 10px;
}
</style>

<div class="title">
   lorem ipsum
   <div class="underline"></div>
</div>

enter image description here

like image 41
CJ Nimes Avatar answered Oct 14 '22 11:10

CJ Nimes