Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h3>The joy of absolute positioning</h3> <pre><code> .on-margin { position: absolute; right: 10%; /* right margin from the containing box */ } </code></pre> <p><strong>How this works:</strong> With absolute positioning, you usually specify one of each <code>right</code>/<code>left</code> and <code>top</code>/<code>bottom</code> pairs of attributes. However, you don't have to: omitting <code>top</code> attribute leaves it at <code>auto</code>, that is, on the current line. </p> <p><strong>Clarification:</strong> after careful reading, I believe the CSS 2.1 specification doesn't mention that it's possible to specify <code>right: 10%; top: auto;</code> and that <em>the specification doesn't prescribe any behavior</em>.</p> <p><strong>Note:</strong> Earlier I specified <code>display:block</code> explicitly. In fact, per <a href="http://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo" rel="nofollow noreferrer">specification</a>, <code>display</code> is automatically changed to <code>block</code> for most absolutely positioned elements. </p> <p><strong>Tested:</strong> Safari 4.0, Firefox 3.6a1pre, Camino 2.0b3, Opera 10.00b1 /Mac</p> <p><strong>References:</strong> <a href="http://www.w3.org/TR/CSS2/visuren.html#propdef-top" rel="nofollow noreferrer">CSS 2.1 visual model</a>, <a href="http://eldercare.vn/so/Floating%20Annotations.html" rel="nofollow noreferrer">my showcase page</a>, <a href="https://stackoverflow.com/questions/365371/css-two-columns/977358#977358">answer to a related question</a>.</p> <p><strong>Re: update.</strong> This perfectly works for large blocks. Note though that HTML doesn't like when <code>div</code>, header or similar 'big' tag is put inside <code>p</code> (and some browsers will break <code>p</code> in this case), so you might have to do some workaround around it. Showcase page updated with example.</p>
 

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