I have this code:
<br><br><br>
<div style="position: relative; background: #000000; height: 400px;">
<span style="position: absolute; top: 0; left: 0; display: block; background: #FF0000; width: 100px; height: 100px;">
</span>
</div>
It works, all I need is the span is located by absolute position compare to the div container.
But when I add an image inside of the div:
<br><br><br>
<div style="position: relative; background: #000000; height: 400px;">
<img src="FabledLeviathan.png">
<span style="position: absolute: top: 0; left: 0; display: block; background: #FF0000; width: 100px; height: 100px;">
</span>
</div>
The span does not display at [0, 0] comparing to the container div as it did before. It now displays under the image. How should I fix this?
You have a small typo in the <span>
's style.
You have a :
after the word absolute
. Should be a ;
<div style="position: relative; background: #000000; height: 400px;">
<img src="FabledLeviathan.png">
<span style="position: absolute; top: 0; left: 0; display: block; background: #FF0000; width: 100px; height: 100px;">
</span>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With