Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do centered <h1> with <hr/> on both sides over a background image
    primarykey
    data
    text
    <p>How do I create centered <code>&lt;h1&gt;</code> with <code>&lt;hr/&gt;</code> on both sides <strong><em>over a background image</em></strong>? </p> <p>I also need it to handle various text lengths, scale well for mobile viewing and have the <code>&lt;hr/&gt;</code> go to 100% width of its container.</p> <p>I want this look, but over a background image. <img src="https://i.stack.imgur.com/ahA8W.png" alt="text on solid background"></p> <p>There are lots of answers (<a href="https://stackoverflow.com/q/2812770/242">here</a>, <a href="https://stackoverflow.com/q/9033823/242">here</a> <a href="https://stackoverflow.com/q/9015309/242">here</a> and <a href="https://stackoverflow.com/q/12648513/242">here</a>) for text with lines on either side but all of them rely on using a solid background colour behind the text, which doesn't work for me as the page I want to put this on has a background image. </p> <p>Here is how I achieve the look above, which handles various lengths of text and scales well:</p> <p><strong>CSS</strong></p> <pre><code>.title-box { height: 2px; background-color: rgb(215, 0, 0); text-align: center; } .title-outer { background-color:rgb(230, 230, 230); position: relative; top: -0.7em; } .title-inner { margin:0px 20px; font-size: 17.5px; font-weight:bold; color:rgb(100, 100, 100); } </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;div class="title-box"&gt; &lt;span class="title-outer"&gt; &lt;span class="title-inner"&gt;OUR STORY&lt;/span&gt; &lt;/span&gt; &lt;/div&gt; </code></pre> <p>I have tried the method below and it <em>kind of</em> works but it doesn't handle various text widths or scale well due to the <code>&lt;h1&gt;</code> and the <code>&lt;hr/&gt;</code>s being in seperate <code>&lt;div&gt;</code>s:</p> <p><img src="https://i.stack.imgur.com/hXsMh.png" alt="text on background image"></p> <p><strong>HTML</strong></p> <pre><code>&lt;div class="row"&gt; &lt;div class="span4"&gt;&lt;hr /&gt;&lt;/div&gt; &lt;div class="span4"&gt;&lt;h4&gt;OUR STORY&lt;/h4&gt;&lt;/div&gt; &lt;div class="span4"&gt;&lt;hr /&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p><em>Note: This is example is using the Bootstrap grid system but that is not part of the problem/solution.</em></p> <p>So any ideas how I can get the same look and behaviour but without the backgound colour for the text so it can sit over a background image?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload