Created
September 5, 2015 05:24
-
-
Save joshuadavidnelson/420f0ff79aa3025f87c1 to your computer and use it in GitHub Desktop.
Add line-on-side headers. Fallback for non-javascript browsers is no lines.
This file contains 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
jQuery(function( $ ){ | |
// Sets the horizontal location of the lines | |
$(document).ready(function () { | |
var entryHeaderWidth = $('.entry-title').width(); | |
var titleWidth = $('.entry-title .title').width(); | |
$('.entry-title span.before').css("right", entryHeaderWidth/2+titleWidth/2 ); | |
$('.entry-title span.after').css("left", entryHeaderWidth/2+titleWidth/2 ); | |
}); | |
}); |
This file contains 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
<h1 class="entry-title"><span class="before"></span><span class="title">%s</span><span class="after"></span></h1> | |
<!-- Optionally: add a .wrap class around all of it and add a width, then overflow: hidden --> |
This file contains 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
.entry-title { | |
text-align: center; | |
display: inline-block; | |
margin: 0 auto 0 auto; | |
position: relative; | |
width: 100%; | |
span.before, | |
span.after { | |
content: ""; | |
position: absolute; | |
border-bottom: 5px solid #000; // This is the line on each side, style as you like | |
top: 50%; // center it vertically | |
transform: translateY(-50%); // center it vertically | |
width: 100%; | |
} | |
span.before { | |
right: 100%; | |
margin-right: 15px; // space between line and text | |
} | |
span.after { | |
left: 100%; | |
margin-left: 15px; // space between line and text | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment