Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your margin value is calculated using the parent elements width. Why? Good question. I don't know but here is some discussion on the topic: <a href="https://stackoverflow.com/questions/11003911/why-are-margin-padding-percentages-in-css-always-calculated-against-width">Why are margin/padding percentages in CSS always calculated against width?</a></p> <p>Here is your demo with the <code>#col3wrap</code> with a width set: <a href="http://jsfiddle.net/Xdwhk/1/" rel="nofollow noreferrer">http://jsfiddle.net/Xdwhk/1/</a></p> <p>Try adjusting the width to see how the margin-top value changes with it.</p> <p>So you're going to have to find a different method, other than using margin-top, to vertically centre your progress bar.</p> <p>Here is one way, using <code>position: relative</code> and <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/calc" rel="nofollow noreferrer"><code>calc</code></a> to set the <code>top</code> value:</p> <p><strong>CSS</strong></p> <pre class="lang-css prettyprint-override"><code>#col3wrap{ height: 50px; background: #DDD; position: relative; } .profilepic { width: 50px; height: 50px; background: red; float: left; margin: 0 10px 0 0; } #progressbarr { float: left; width: 300px; height: 20px; background: #eee; position: relative; top: 30%; top: -webkit-calc(50% - 10px); top: calc(50% - 10px); } #progressbarr &gt; div { background-color: green; width: 40%; height: 20px; } </code></pre> <p><strong><a href="http://jsfiddle.net/Xdwhk/3/" rel="nofollow noreferrer">Demo</a></strong></p> <p>Note <a href="http://caniuse.com/calc" rel="nofollow noreferrer">calc</a> is not supported by all browsers so we must have a fall back.</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