Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I've played a bit with this code and here is my solution. Yes, it's a bit dirty because I've used <code>:before</code> and <code>:after</code>, but works.</p> <p><strong>HTML</strong></p> <pre><code>&lt;div class="title-box"&gt; &lt;span id="first" class="title-inner"&gt;OUR LOOOoo oooo oOONG STORY&lt;/span&gt; &lt;/div&gt; &lt;div class="title-box"&gt; &lt;span id="second" class="title-inner"&gt;OUR STORY&lt;/span&gt; &lt;/div&gt; &lt;div class="title-box"&gt; &lt;span id="third" class="title-inner"&gt;STORY&lt;/span&gt; &lt;/div&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>.title-box { text-align: center; } .title-inner { margin:0px 20px; font-size: 17.5px; font-weight:bold; position: relative; color:rgb(100, 100, 100); } .title-inner:after, .title-inner:before { content:""; float: right; position: relative; top: 8px; height: 2px; background: red; } .title-inner:before { float: left; } </code></pre> <p><strong>jQuery</strong></p> <pre><code>$(document).ready(function () { function work() { $(".title-inner").each(function () { var full_width = $(window).width(); var id = $(this).attr("id"); var title_width = $("#" + id).width(); var new_width = (full_width - title_width) / 2 - 40; $('head').append("&lt;style&gt;#" + id + ":before, #" + id + ":after{width:" + new_width + "px !important;}&lt;/style&gt;"); }); } work(); $(window).resize(function () { work(); }); }); </code></pre> <p><a href="http://jsfiddle.net/ffb3X/4/" rel="nofollow">http://jsfiddle.net/ffb3X/4/</a></p> <p>Because <code>:before</code> and <code>:after</code> are not part of DOM, I've used <code>.append()</code> function to append style tags in head for every title.</p> <p>This code will on page load calculate everything, so it's responsive.</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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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