Why the top attribute of
does not work when the label
is the same level as
, but This works if I remove the tag
.
html, body { height: 100%; } img { position: relative; top: 40%; }
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Temporibus delectus accusantium nulla eveniet aperiam, quo odit qui voluptas. Illo vel sed ex dolores illum eum architecto a libero atque. Voluptatibus.</p> <img src="http://lorempixel.com/400/200/" alt="">
P粉5210131232023-10-30 11:16:49
Use a container div
set to position:relative;
and then add position:absolute;
to the img.