Jump to content

Recommended Posts

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



<!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>


@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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...