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