I am trying to create two borders one on the left and one on the right and the main text is in the middle of the two borders.
An example to idea to what I am trying to achieve I have uploaded two sample images.
I tried doing it this way but the two lines come together.
<div class="www">
<h4><span class="lineseparator"></span>
TITLE NOT TITLE
<span class="lineseparator"></span>
</h4>
<p>Content and content and contecnt</p>
</div>
I tried this other way but same problem.
<div class="www">
<span class="lineseparator"></span>
<h4>TITLE NOT TITLE</h4>
<span class="lineseparator"></span>
<p>Content and content and contecnt</p>
</div>
Execution:
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-size: 13px;
font-family: 'OpenSans', 'cursive', 'Releway', Roboto, Lato, Utsaah;
background-color: #FBFBFB;
}
.www {
position: relative;
padding-top: 35px;
}
.lineseparator {
height: 1px;
border-top: 1px solid #000;
display: block;
position: relative;
top: 12px;
width: 20%;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 300;
}
p {
font-size: 15px;
line-height: 24px;
font-weight: 300;
}
<div class="www">
<span class="lineseparator"></span>
<h4>TITLE NOT TITLE</h4>
<span class="lineseparator"></span>
<p>Content and content and contecnt</p>
</div>
<br><br><br>
<div class="www">
<h4><span class="lineseparator"></span>
TITLE NOT TITLE
<span class="lineseparator"></span>
</h4>
<p>Content and content and contecnt</p>
</div>
What I want to achieve is the following example I take it from a website.
And that when making responsive it adapts in the following way.
Try the following:
What you want to do can be done in different ways. An easy way would be for example using a pseudo-element
::after
to make the line horizontal, and then overlaying the text with onespan
that has the same background as the page.Something like this:
Another way to do it would be to use the pseudo-elements
::before
and::after
together with Flexbox. This method is (or at least it seems to me) quite interesting because no additional tags are needed, it will justh4
work with it.The idea is:
display:flex
to header.::before
and::after
empty with a top border.flex:1
pseudo-elements to take up all available space.And here you can see it working:
Something like this but curved?