html - how to use images plus repeating background in <h1> -


i'm trying create <h1> has text centered, image on each side, , dynamically fill in lines remaining width of container.

i've tried few techniques... using :before , :after, nested span. :after working, trying solve :before part.

fiddle: jsfiddle.net/dtar4rgs/

you can use flex achieve you're looking (demo (supports flexbox), demo (doesn't support flexbox)):

<div id="container">     <h1><span>a b c</span></h1>     <p>change text shorter or longer.</p>     <p>need left lines dynamic.</p> </div> 
h1 {     display:flex; /* treats :before, :after, , span individual items */     align-items:center; /* aligns items vertically (to align border properly) */     text-align:center; /* aligns items horizontally browsers don't support flexbox */ } h1 span {     /* places arrow on each side of span */     background: url('https://dl.dropboxusercontent.com/u/101534624/arrow_cyan.gif') no-repeat left,     url('https://dl.dropboxusercontent.com/u/101534624/arrow_cyan.gif') no-repeat right;     padding: 0 50px; /* prevents text overlapping image */ } h1:before, h1:after {     content: " ";     /* lines on sides of header */     background: url('https://dl.dropboxusercontent.com/u/101534624/h1-lines.png') repeat-x;     height: 6px; /* height of lines */     flex-grow:1; /* makes lines expand edges of screen */ } 

note: support flexbox lacking (ie11+), text-align:center, difference lack of lines.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -