Make element height inversely proportional to width- pure css
jsfiddle.net
jsfiddle.net
It looks like the content is resizing in chrome based on the number of characters in the :before tag. is that right?
So in this case the width is a percentage of the total, but the height is determined by the total number of chars in the :before
So the :before pseudoelement on #container has a bunch of _'s and spaces that reflow like any text will. #element has the actual content, and is absolutely positioned to the edges of its parent.
So as the width changes, the text in the :before element reflows and expands #container's size. #element simply follows the size of #container. The :after pseudoelement is just there for decoration.
fake-truncate(num)
fill(num)
buf = ''
for index in 1..num
buf += '_ '
position: relative
overflow: hidden
&:before
content: fill(num)
visibility: hidden
display: block
._content
position: absolute
top: 0
bottom: 0
left: 0
right: 0