I've been asked to create this title, purely with css, Is it even possible?
The background of the text needs to remain transparent, the h2 needs to span the width of any container and have the left and right borders fill automatically the remaining space.
h2 {
font-size:42px;
line-height:48px;
width:100%;
overflow: hidden;
&:before {
content:'';
position:relative;
padding-left:50px;
padding-right:10px;
margin-right:10px;
margin-bottom:10px;
background:red;
height:3px;
display:inline-block;
}
&:after {
content:'';
margin-left:10px;
width:100%;
background:red;
height:3px;
display:inline-block;
}
}
The left side is easy, however I'm stuck on the right side.
https://jsfiddle.net/kab5qtbb/
I can't seem to figure out how to only make the right line fill the remaining space on the right of the container.
Here is solution using
display: table;
and
display: table-cell;
The lines on the side grow and shrink after the content of the header.
the html is:-
you also need to add background image or to use css3-gradients.This is what Im using :)
https://jsfiddle.net/v7gze6ox/2/
If you are not too fussed about absolute positioning, you can do
will need tweaking but in jsfiddle this gets you what you need
You can use
margin-right:-100%;
andvertical-align:middle;
on the:after
pseudo element. (Based on this answer: Line separator under text and transparent background) :Note that I also simplified your CSS.