473,396 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't center webpage?

I'm building my first website without any prior knowledge of html or css programming, so noob question here: I cannot align my website's homepage to the center. I've tried trouble shooting this for a few hours, and none of the solutions work.

I have all of my images in a DIV called wrap. Whatever I try, it doesn't seem to affect it's positioning.

Also, please ignore any alignment issues with the images, I've jumbled everything's position up while trying to get this right.

Thanks for the help!





Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  7. <title>Lizzy's Web Page</title>
  8. <style type="text/css">
  9.  
  10.  
  11. body {
  12.     background-color: #ece5e5;
  13. }
  14.  
  15.  
  16.  
  17.  
  18. #wrap {
  19.     width:1200px;
  20.     height:816px;
  21.     margin-top: 0px;
  22.     margin-right: auto;
  23.     margin-bottom: 0px;
  24.     margin-left: auto;
  25.  
  26.  
  27. }
  28.  
  29. #HarryDiv {
  30.     position:absolute;
  31.     left:939px;
  32.     width:496px;
  33.     height:674px;
  34.     z-index:2;
  35.     bottom: 4px;
  36.     margin-top: 55px;
  37. }
  38. #name {
  39.     position:absolute;
  40.     left:593px;
  41.     top:30px;
  42.     width:300px;
  43.     height:358px;
  44.     z-index:2;
  45. }
  46. #apDiv2 {
  47.     position:absolute;
  48.     left:209px;
  49.     top:8px;
  50.     width:436px;
  51.     height:410px;
  52.     z-index:2;
  53. }
  54. #contact {
  55.     position:absolute;
  56.     left:625px;
  57.     top:528px;
  58.     width:73px;
  59.     height:41px;
  60.     z-index:1;
  61. }
  62. #about {
  63.     position:absolute;
  64.     left:636px;
  65.     top:474px;
  66.     width:51px;
  67.     height:37px;
  68.     z-index:1;
  69. }
  70. #work {
  71.     position:absolute;
  72.     left:637px;
  73.     top:418px;
  74.     width:47px;
  75.     height:39px;
  76.     z-index:1;
  77. }
  78. #blog {
  79.     position:absolute;
  80.     left:643px;
  81.     top:586px;
  82.     width:39px;
  83.     height:44px;
  84.     z-index:1;
  85. }
  86. #cat {
  87.     position:absolute;
  88.     left:245px;
  89.     top:384px;
  90.     width:343px;
  91.     height:290px;
  92.     z-index:1;
  93. }
  94. </style>
  95.  
  96.  
  97. <script type="text/javascript">
  98. function MM_swapImgRestore() { //v3.0
  99.   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  100. }
  101. function MM_preloadImages() { //v3.0
  102.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  103.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  104.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  105. }
  106.  
  107. function MM_findObj(n, d) { //v4.01
  108.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  109.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  110.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  111.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  112.   if(!x && d.getElementById) x=d.getElementById(n); return x;
  113. }
  114.  
  115. function MM_swapImage() { //v3.0
  116.   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  117.    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  118. }
  119.  
  120. </script>
  121.  
  122.  
  123. </head>
  124.  
  125.  
  126.  
  127. <body onload="MM_preloadImages('Images/butterhead_angry.png')">
  128.  
  129.  
  130. <div id="wrap">
  131.  
  132.  
  133.     <div id="HarryDiv"><img src="Images/harry.png" alt="harry" width="501" height="678" class="harry" /></div>
  134.  
  135.     <div id="name"><img src="Images/lizrodriguez.png" width="305" height="360" alt="name" /></div>
  136.  
  137.     <div id="apDiv2"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Professor Head','','Images/butterhead_angry.png',1)"><img src="Images/butterhead.png" name="Professor Head" width="441" height="408" border="0" id="Professor Head" /></a></div>
  138.  
  139.     <div id="work"><img src="Images/work.png" width="47" height="37" alt="work" /></div>
  140.  
  141.     <div id="about"><img src="Images/about.png" width="51" height="37" alt="about" /></div>
  142.  
  143.     <div id="contact"><img src="Images/contact.png" width="72" height="40" alt="contact" /></div>
  144.  
  145.     <div id="blog"><img src="Images/blog.png" width="39" height="45" alt="blog" /> </div>
  146.  
  147.     <div id="cat"><img src="Images/henryhead.png" width="332" height="283" alt="henry" /> </div>
  148. </div>
  149.  
  150.  
  151.  
  152. </body>
  153. </html>
  154.  
Jan 17 '13 #1
2 1746
Anas Mosaad
185 128KB
Your page is already centred (i.e. div with id wrap) but you are using absolute positioning which cause to appear as you see it.
Jan 17 '13 #2
in body
Expand|Select|Wrap|Line Numbers
  1.  body {
  2.     min-width:960px;
  3.     background-color: #ece5e5;
  4. }

Once try this
Feb 25 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: The Plankmeister | last post by:
Hi... What's an equivalent of doing: <center>hello!</center> in 4.01 strict? I'm using stylesheets and am telling the various selectors I want to be centred to "text-align : center;" but...
0
by: Ray Mitchell | last post by:
I'm using VS 2002 w/available component updates. I am creating a listview with multiple columns. When I use the "ColumnHeader Collection Editor" to specify that the header titles are to be...
1
by: John Dalberg | last post by:
I am trying to center a checkbox in a datagrid column but the checkbox always displays to the right. Below is the rendered html. I also used a css-class with the same text-align: center attribute....
6
by: tgmcnaughton | last post by:
I have a javascript running on a page hosted by googlepages at: http://tgmcnaughton.googlepages.com/map2.htm It uses the google map api to draw a map and plot a marker at a particular latitude and...
2
by: tcontradiction | last post by:
it can be seen on my page at http://total-contradiction.com/index3.html i have the frames i want them but i the page in the center of the screen. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
0
by: gaurav92K | last post by:
sir, we write www.google.com in explorer address bar. then we get the google home page.so i want to know what is the background process for viewing this page.i mean where request goes first and go...
6
by: Studlyami | last post by:
Hey all, I'm trying to create a simple (I think it should be simple) batch file. I want this file to open Internet Explorer 6 go to the webpage SIRIUS Satellite Radio - The Best Radio On Radio and...
3
by: xtoughyx | last post by:
I work for a company which assigns me tasks via their own online portal/webpage which requires a log-in. These tasks are posted very irregularly, and there are frequently long periods in which no...
9
by: dragon52 | last post by:
I am trying to build a banner at the top of a web page. This banner is just 3 div sections running across the top of the page, a large middle one and 2 little ones on either side. See code here ...
1
by: kirk kirk | last post by:
I have user controls which serves as a new interface for the gui (i.e. the main form has buttons like new, records, help, and a main panel where i put my user control). My form works fine in its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.