Is possible using Bootstrap, add a border bottom with 3rem of width (for example) with a class, and add the parameter of color in the tag? Example:
JavaScript
x
11
11
1
.half-title:after{
2
content: "";
3
display: block;
4
width: 3rem;
5
height: 4px;
6
margin-top: .75rem;
7
background: Red;
8
}
9
10
<h1 class="half-title">THIS IS A TITLE</h1>
11
OK. But I want something like this:
JavaScript
1
10
10
1
.half-title:after{
2
content: "";
3
display: block;
4
width: 3rem;
5
height: 4px;
6
margin-top: .75rem;
7
}
8
9
<h1 class="half-title bg-red">THIS IS A TITLE</h1>
10
Is this possible? Thank you.
https://jsfiddle.net/fekula/m3ydro1q/1/
Advertisement
Answer
Thank you focus.style for your suggestion regarding using codes snippet to better demonstrate the result.
Change the background-color and instead use border for your underline, then you’ll be able to use Bootstrap classes to change the underline colour.
JavaScript
1
9
1
.half-title:after{
2
border: solid 4px transparent;
3
border-color: inherit;
4
content: '';
5
display: block;
6
height: 0;
7
margin-top: .75rem;
8
width: 3rem;
9
}
JavaScript
1
9
1
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" />
2
3
<h1 class="half-title border-default">THIS IS A TITLE</h1>
4
5
<h1 class="half-title border-info">THIS IS A TITLE</h1>
6
7
<h1 class="half-title border-warning">THIS IS A TITLE</h1>
8
9
<h1 class="half-title border-danger">THIS IS A TITLE</h1>