Consider this snippet of code below
<div>
<img src="http://www.lorempixel/100/200" />
<p>
Bla bla bla bla
</p>
</div>
I am trying to figure out how to move the image 50% of its height and also adjust the position of the <p>
tag. Any suggestions?
- Using margin and padding percentages is based on the width of the parent element
- The top property can only be applied to elements with certain positions without affecting nearby elements
- The translate function does not impact layout positioning
One approach could involve storing image ratios in an attribute then moving the image by 50% divided by its ratio (utilizing its height). However, there seems to be no way to use this attribute in CSS as attr()
cannot be used outside of a content
context.
Additionally, I prefer to avoid using JavaScript for handling resize events.
Given that it's a responsive website, hardcoding margin values is not ideal.
Am I overlooking an obvious solution here?
Thank you