Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do i make numbers expand left and right over a centrally positioned CSS element?
    primarykey
    data
    text
    <p>I have been wracking my head trying many different methods trying to achieve an effect for a health element.</p> <p>What I want to happen is have a central median push a value left, and push another value right.</p> <p>I have tried floats, which kind of work, but does not give me the effect I am looking for.</p> <p>Positioning absolutely causes them to overlap the central median when exceeding a certain length.</p> <p>Here's what ALMOST gets it right.</p> <pre><code>.travel-spacing { margin-bottom: 20px; } .stat-wrapper { height: 170px; width: 150px; } .stat-label-align { float: left; width: 150px; margin: 0 auto; text-align: center; } .stat-align { float: left; width: 150px; margin: 0 auto; text-align: center; } .val-1 { float: left; position: relative; margin-left: 35px; } .center-divide-h { position: absolute; width: 150px; margin: 45px auto auto -150px; text-align: center; } .center-divide-m { position: absolute; width: 150px; margin: 60px auto auto -150px; text-align: center; } .center-divide-s { position: absolute; width: 150px; margin: 75px auto auto -150px; text-align: center; } .val-2 { float: right; margin-right: 35px; } </code></pre> <p>This is the PHP:</p> <pre><code>&lt;div class="stat-wrapper"&gt; &lt;?php echo "&lt;div class ='stat-label-align'&gt;Level:&lt;/div&gt; &lt;span class=\"stat-align\"&gt;" . $playerLevel . "&lt;/span&gt;"; ?&gt;&lt;br /&gt; &lt;?php echo "&lt;div class ='stat-label-align'&gt;Exp:&lt;/div&gt; &lt;span class=\"stat-align\"&gt;" . $playerExp . "&lt;/span&gt;"; ?&gt;&lt;br /&gt; &lt;?php echo "&lt;div class ='stat-label-align'&gt;Health:&lt;/div&gt; &lt;span class=\"val-1\"&gt;" . $maxHealth . " &lt;/span&gt;&lt;span class='center-divide-h'&gt;/&lt;/span&gt;&lt;span class='val-2'&gt; " . $maxHealth . "&lt;/span&gt;"; ?&gt;&lt;br /&gt; &lt;?php echo "&lt;div class ='stat-label-align'&gt;Mana:&lt;/div&gt; &lt;span class=\"val-1\"&gt;" . $maxMana . " &lt;/span&gt;&lt;span class='center-divide-m'&gt;/&lt;/span&gt;&lt;span class='val-2'&gt; " . $maxMana . "&lt;/span&gt;"; ?&gt;&lt;br /&gt; &lt;?php echo "&lt;div class ='stat-label-align'&gt;Stamina:&lt;/div&gt; &lt;span class=\"val-1\"&gt;" . $maxStamina . "&lt;/span&gt; &lt;span class='center-divide-s'&gt;/&lt;/span&gt;&lt;span class='val-2'&gt; " . $maxStamina . "&lt;/span&gt;"; ?&gt;&lt;br /&gt; &lt;?php echo "&lt;div class ='stat-label-align'&gt;Coins:&lt;/div&gt; &lt;span class=\"stat-align\"&gt;" . $money . "&lt;/span&gt;"; ?&gt;&lt;br /&gt; &lt;/div&gt; &lt;div class="travel-spacing"&gt;&lt;/div&gt; </code></pre> <p>How I want it:</p> <pre><code> 5 / 5000 40 / 5000 </code></pre> <p>It is not as clean as I normally do it, but was trying everything I could think of. Thanks for any insight!</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.
 

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