Created
December 11, 2014 02:29
-
-
Save omurphy27/54ab5e958c783c7e9ada to your computer and use it in GitHub Desktop.
Horizontal line on each side of heading with no background color or extra markup CSS HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lines on other side of a heading | |
// without using extra markup or a background color | |
// the css | |
h1 { | |
overflow: hidden; | |
text-align: center; | |
} | |
h1:before, | |
h1:after { | |
background-color: #000; | |
content: ""; | |
display: inline-block; | |
height: 1px; | |
position: relative; | |
vertical-align: middle; | |
width: 50%; | |
} | |
h1:before { | |
right: 0.5em; | |
margin-left: -50%; | |
} | |
h1:after { | |
left: 0.5em; | |
margin-right: -50%; | |
} | |
// the markup | |
<h1>Heading</h1> | |
<h1>This is a longer heading</h1> | |
// credit: http://puigcerber.com/2013/03/08/centered-heading-overlaying-a-horizontal-line-with-css/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment