Issue
I want to create horizontal line on left side of my text. I have somethink like this, but it's creating line on both sides but I want only on one side - left or right. How can I do this?
h2 {
width: 100%;
text-align: center;
border-bottom: 1px solid #000;
line-height: 0.1em;
margin: 10px 0 20px;
}
h2 span {
background: #fff;
padding: 0 10px;
}
Demo: http://jsfiddle.net/7jGHS/
Solution
With your current HTML structure you can use Flexbox
and :after
, :before
pseudo elements to do this.
h2 {
display: flex;
align-items: center;
justify-content: center;
}
h2 span {
background: #fff;
margin: 0 15px;
}
h2:before,
h2:after {
background: black;
height: 2px;
flex: 1;
content: '';
}
h2.left:after {
background: none;
}
h2.right:before {
background: none;
}
<h2 class="left"><span>THIS IS A TEST</span></h2>
<h2 class="right"><span>LOREM</span></h2>
<p>this is some content</p>
Answered By - Nenad Vracar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.