Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Updated method</h2> <p>Here is a way to do what was asked that is so simple that I overlooked it at first.</p> <pre><code>height: 100%; width: 100%; -webkit-transform: rotate(90deg) ; -moz-transform: rotate(90deg) ; -ms-transform: rotate(90deg) ; -o-transform: rotate(90deg) ; transform: rotate(90deg); </code></pre> <p>This works because the width and height are set before the element is transformed. <code>transform-origin</code> may be useful to help position this correctly.</p> <p>If you need the content to be rotated correctly, you should be able to use text rotation.</p> <p>Fiddle: <a href="http://jsfiddle.net/p4nLX/1/" rel="nofollow noreferrer">http://jsfiddle.net/p4nLX/1/</a></p> <h2>Original answer</h2> <p>Well here is a way to transfer parent width to the height of the <code>:before</code>:</p> <pre><code>div { width: 300px; height: 100px; background-color: red; } div:before { content: ''; display: block; padding-bottom: 100%; background-color: blue; width: 100px; } </code></pre> <p>Percentage padding (and margin I think) are based on the width of the parent element.</p> <p>Fiddle: <a href="http://jsfiddle.net/p4nLX/" rel="nofollow noreferrer">http://jsfiddle.net/p4nLX/</a></p> <p>Based on this answer: <a href="https://stackoverflow.com/questions/5814810/target-before-and-after-pseudo-elements-with-jquery#5814824">Target :before and :after pseudo-elements with jQuery</a> you can use the jQuery plugin here: <a href="http://jquery.lukelutman.com/plugins/pseudo/jquery.pseudo.js" rel="nofollow noreferrer">http://jquery.lukelutman.com/plugins/pseudo/jquery.pseudo.js</a> to target pseudo elements. From a quick look it seems the plugin transfers the pseudo elements content into a <code>&lt;span&gt;</code> so it can be targeted as a pseudo element is not part of the DOM.</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.
 

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