Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

aligning divs 1

Status
Not open for further replies.

JKdesignz

Technical User
Feb 2, 2005
18
0
0
NL
i need a hand on this one, i inserted an image into a div, this image is meant to be my welcome page with 'enterpage'link. the image is 800x600 but.... it is aligning in the left of my page. i tried to align the div where i put the image in the center, but i actually don't kno how, who can help?
my css-code:
Code:
#background  {position: absolute; left: 0 px; top: 0 px;}
my xhtml-code:
Code:
<div id="background">
  	<img  src="enterpage.jpg" width="800px" 
  	height="600px" alt="background" />
</div>

note: the image must stay aligned in the center, even when window size is changed

Thou shalt be victorious!!
 
You will need your background div to be 760 wide to avoid horiz scrollbars at 800 wide.

Code:
body {
margin:0px 0px 0px 0px;
text-align:center;
}
#background {
text-align:left;
width:760px;
background-image: url(/enterpage.jpg);
background-repeat: no-repeat;
margin:0px auto 0px auto;

Code:
<div id="background">

</div>

Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
Nightclub counting systems

So long, and thanks for all the fish.
 
What's with the background div? What you're trying to achieve is pretty simple:
Code:
<div style="text-align: center;"><img  src="enterpage.jpg" width="800px" height="600px" alt="background" /></div>
Of course, if that absolutely positioned div should act as a background for the page, than it is again a mystery to my why you did not use:
Code:
body {
  background: white url(enterpage.jpg) center center no-repeat;
}
Whatever it is, tell us why you need the absolutely positioned div, because as hard as I try, I can't find a use for it in your case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top