Jump to content

Center page


enimy6

Recommended Posts

My page was centered in the web page, but now it isn't anymore.. this is my code

 

html:

<!doctype html><html><head><link href="../css/style.css" rel="stylesheet" type="text/css"/><meta charset="utf-8"><title>Events</title></head><body><div id="page"><div id="logo"><img src="../images/ETlogo.jpg"></div><header><h1> Latest Electric Car News </h1></header><nav><ul><li><a href="home.html">Home</a></li><li><a href="Staff.html">Staff</a></li><li><a href="Subscription.html">Subscription</a></li><li><a href="Events.html" class="current">Events</a></li><li><a href="News.html">News</a></li><li><a href="Sitemap.html">Sitemap</a></li></ul></nav><article><h1>Events</h1></article><footer>Sitemap</footer></div></body></html>

CSS:

@charset "UTF-8";/* CSS Document */##page{	margin-left:auto;	margin-right:auto;	width:1024px;}li{	list-style-type:none;}#logo{	width:203px;	height:183px;	display:inline-block;	text-align:center;	border-right:solid 1px #999999;	position:fixed;}header{	background-color:#FFF;	width:100%;	width:600px;	height:85px;	float:left;	padding-top:30px;		padding-left:20px;	margin-left:203px;	border-left:solid 1px #999999;	}p{	font-size:100%;	font-family:Georgia, "Times New Roman", Times, serif;	}h1{	font-size:30px; 	font-family:Georgia, "Times New Roman", Times, serif;	color:#B90000}h4{	font-family:Georgia, "Times New Roman", Times, serif;	font-size:16px;	margin-bottom:auto;	color:#B90000;}nav {	float:left;	width:203px;	border-right:solid 1px #999999;	height:clear;	background-color:#FFF;	position:fixed;	margin-top:200px;	}nav a{	color:#B90000;	font-size:18px;	text-decoration: none}nav a:active{	font-weight:800;	text-align:right;}nav a:visited {  }    nav a.current:link, a.current:visited {	font-weight:900;}  article{	padding:10px;	width:600px;	display:block;	float:left;	background-color:#FFF;	border-top:solid 1px #999999;	border-left:solid 1px #999999;	margin-left:203px;}form glowing-border {    border: 2px solid #dadada;    border-radius: 7px;}form glowing-border:focus {     outline: none;    border-color: #9ecaed;    box-shadow: 0 0 10px #9ecaed;}input{	width:400px;	margin-bottom:10px;}footer{	clear:both;	width:100%;	height:30px;	border-top:solid 1px #999999;	border-radius:5px;}	

Why won't it position in the center of the page?

Link to comment
Share on other sites

Which part of the page isn't centered?

 

#logo, for example, has position:fixed, so that would prevent it from being centered.

 

I'm not sure what this is supposed to do: The second width rule overrides the first one.

header{    background-color:#FFF;    width:100%;    width:600px;

nav has "position:fixed;" as well so I can't predict how that's going to behave, but it most likely won't be centered in any way.

 

Remove all your position:fixed declarations, and try to make your CSS rules coherent.

Link to comment
Share on other sites

Okay, so I've figured out the problem, because of of 'fixed' my entire 'container' gets dragged to the side, (like this: http://oi41.tinypic.com/2lnwx0.jpg)

getting rid of 'position:fixed' would get rid of the problem, but I want the left side of the website to 'not-move' and the right side to move when the user scrolls through the content.., how would I do this without using 'fixed'?

 

and with 'center' the webpage I mean, have whitespace on both left and right, the code 'margin-left:auto;' and right, should take care of that

Link to comment
Share on other sites

then you want to separate the page into 2 divs. the 1st div will have the nav and will have, say width:25%, height:100%, and position:fixed, the 2nd div will have all the rest of the stuff on the page and will have width: 75%, position:relative, and left:25%. then you can use margins and stuff inside that div to center and align content for the right section of the page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...