PDA

View Full Version : Text and background in center?


IFeelYourPain
08-21-2008, 09:02 PM
I haven't made a website in awhile. I'm wondering how exactly to make text in the center. I have a background with borders that I have placed in the center.
body {
background-color: #FFFFFF;
background-image: url(back.jpg);
background-repeat: repeat-y;
background-position: center;
}

Now I'm wanting the text to start right after the border no matter what screen resolution you have. So I tried adding body margin-left: 35%; like so:
body {
background-color: #FFFFFF;
background-image: url(back.jpg);
background-repeat: repeat-y;
background-position: center;
margin-left: 35%;
}

However when resizing the screen it would go away from the border. I tried px and it did the same thing. Any advice?

VIPStephan
08-21-2008, 09:28 PM
Not sure what you mean unless you show an online example. But what about a left padding?

IFeelYourPain
08-21-2008, 11:54 PM
Not sure what you mean unless you show an online example. But what about a left padding?

Look at the attachment, thats an example of what I am looking for. I did it along time ago, but it's been forever since I have done anything website related.

VIPStephan
08-22-2008, 12:10 AM
Oh I see. OK, the background image has a certain width, right? Now make the body width the same as the image’s width and apply margin: auto;

IFeelYourPain
08-22-2008, 12:59 AM
Oh I see. OK, the background image has a certain width, right? Now make the body width the same as the image’s width and apply margin: auto;

How would I go about making the body width the same as the images width?

twodayslate
08-22-2008, 01:09 AM
<body>
<div class="container">If BG is 500px wide use this code</div>
</body>


body {}
.container { margin: 0 auto; width: 500px; }