unidox Posted March 25, 2008 Share Posted March 25, 2008 I have a background image and some text. What I am trying to do is have the text move to the left 12px and be vertical centered in the bg. Everytime I try to add a margin it moves the bg over 15 px also. How do I do this? Link to comment https://forums.phpfreaks.com/topic/97803-how-would-i/ Share on other sites More sharing options...
gruzaw Posted March 25, 2008 Share Posted March 25, 2008 as long as the background is centered, the test will be centered too. put the text in a div and use <div style='position:absolute; left:*px and just allign it as you wish. * is the number of pixels the div will be away from the left. Link to comment https://forums.phpfreaks.com/topic/97803-how-would-i/#findComment-500424 Share on other sites More sharing options...
dbrimlow Posted March 25, 2008 Share Posted March 25, 2008 You DON'T want the margin move 12px you want 12px of padding. Margin makes the whole box move ... no the contents. Try padding:15px. Also, avoid using "position:absolute" at all costs unless you really know what you are doing. Unless your container with the background image is designated as "position:relative", your text as "position:absolute" takes it out of the flow of html altogether. (which would by default move it to the top left of the browser's window). Link to comment https://forums.phpfreaks.com/topic/97803-how-would-i/#findComment-500622 Share on other sites More sharing options...
zang8027 Posted April 2, 2008 Share Posted April 2, 2008 i would surround your text (granted its inline) with span tags <span class="whatever">TEXT</span> .whatever { margin-left:-12px; } also, try having your background image in the body {background-image:URL(ahashshA);} and have all other div tags in a wrapper.. then your background should not move.. unless the background is strictly for the div tag.. then use spans Link to comment https://forums.phpfreaks.com/topic/97803-how-would-i/#findComment-507174 Share on other sites More sharing options...
haku Posted April 2, 2008 Share Posted April 2, 2008 Zang: that's overkill. Way more code than is necessary. Dbrimlow gave a good solution. Link to comment https://forums.phpfreaks.com/topic/97803-how-would-i/#findComment-507542 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.