Getting my text to go over the background image
I have this code:
<div style="background-image: url('images/middle.png'); height: 390px; width: 900px; margin-top:190px; color:#000000;">
</div>
which produces this:
But when i put text in the div, no matter how much margi开发者_Python百科ns or anything i put on it does this:
But i want the text be on the white image.
Any ideas?
You need padding
rather than margin
.
The margin
is of no use for this use padding
. I tried with the following and it worked!
<div style="background-image: url("http://i.stack.imgur.com/uisvJ.png"); height: 390px; width: 900px; color: rgb(0, 0, 0); margin-top: 0px; padding-left: 35px; padding-top: 25px;">
my text appears here and on top of the image
</div>
<div style="background-image: url('images/middle.png'); height: 390px; width: 900px; margin-top:190px; color:#000000; >
<div style="text-align:center;padding-top:XXXXXXpx">Hello there</div>
</div>
set padding-top:XXXXXXpx to what ever you need;
second solution is to set in inner div style to margin: top auto; and width: 100px (if it is enough for text, can be less or more) Change top in pixels how much you need your text be far from outer div
Also, next time, please add more in description, like where that text should appear :)
精彩评论