Zum Inhalt springen

HILFE - Seite im Broweser zentrieren

Erstellt am 22. April 2013 · 6 Antworten · letzte Antwort am 23. April 2013

Tags: HTML & CSS, TYPO3 4, Frage

DonKB ·

Liebe Typo3-Gemeinde,

bin relativ unerfahren mit Typo3 (Version 4.2.9) und soll nun für meinen Chef eine bestehende Website "modernisieren". Unsere Seite wird in den Browsern linksbündig dargestellt, doch ich will sie zentriert haben.

Meine Frage: Mit welchen Befehlen bekomm ich die Seite zentriert.

Hier css:

*/
html, body, div, span, h1, h2, h3, h4, p, hr, table, tr ,td, th, a, ul, li, form, select, input, submit, label {
  margin:0;
  padding:0;
  font-family:Verdana,Helvetica,Jamrul,sans-serif;
  color:#000000;
  font-size:11px;
}

p {
  padding-left:15px;
  padding-top:0px;
  padding-bottom:9px;
  padding-right:15px;
  line-height:15px;

}
h1 {
  padding-left:0px;
  padding-right:15px;
  padding-bottom:0px;
}


h2 {
  padding-left:15px;
  padding-right:15px;
  padding-bottom:5px;
  padding-top:20px;
  line-height:15px;
}
h3 {
  padding-left:15px;
  padding-right:15px;
  padding-bottom:5px;
  padding-top:20px;  
}

p.yellow {
  background-color:#f0e40a;
  height:147px;

}
p.yellow a {
  color:#000000;
}

p.green {
  background-color:#007770;
  color:#FFFFFF;
  height:147px;
}

p.green a {
  color:#FFFFFF;
}

p.brightgreen {
  background-color:#76bab2;
  height:147px;
}
p.brightgreen a {
  color:#000000;
}


img {
  margin:0;
  padding:0;
}

html, body, div, span, h1, h2, h3, p, hr, table, tr ,td, th, a {
  border:0;
}

* {
  margin:0;
  padding:0;
}

html, body {
  height: 100%;
  width: 100%;
}


a:hover {
  text-decoration:underline;
}
a {
  text-decoration:underline;
  color:#000000;
}




/* 
   =================================================================
     STRUKTUR 
   =================================================================
*/



#wrapper_content {
  position:absolute;
  top:40px;
  left:40px;
}

#content {
  float:left;
  width:950px;
}

#top {
  height:125px;
}

#logo {
  position:absolute;
  top:0px;
  left:0px;
}

#menu_main {
  position:absolute;
  top:60px;
  left:30px;
  width:100%;
  height:65px;;
}
#menu_main img {
 border:0px;
}
  

#menu_impressum {
  position:absolute;
  top:60px;
  left:740px;
  width:210px;
  height:65px;;
  text-align:right;
}
#menu_impressum img {
 border:0px;
}

#middle {
  position:absolute;
  left:15px;
  float:left;
  width:735px;
  min-height:200px;
}

Hier der html:

<html>
	
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<link rel="stylesheet" type="text/css" href="main.css" />
<head>

<body>
<!--###DOCUMENT###-->
<div id="wrapper_content">
	<div id="content">
		<div id="top">
			<div id="logo"><a href="index.php"><img src="fileadmin/layout/logo.gif" width="150" height="45" border="0" ></a></div>
			<div id="menu_main">###MAINMENU###<br>###SUBMENU###</div>
			<div id="menu_impressum">###IMPRESSUMMENU###</div>
		</div>
		<div id="middle">
			###CONTENT###
		</div>
	</div>
</div>
</div>
<!--###DOCUMENT###-->	
</body>
</html>

Bitte, bitte helft mir, da ich gerade voll auf dem Schlauch stehe und dringend ein Ergebnis brauche. Vielen Dank. DonKB

vince ·

Hallo,

das geht mit css, z.B. so:

body{
  width : 1000 px; /* oder irgendein andere Wert */
  margin : auto;
}

Gruß,
Vince.

DonKB ·

Hallo Vince,

danke für deinen Vorschlag. Hab ich gleich mal ausprobiert, doch leider tut sich da nix, wenn ich den neuen Code in css einbaue.

Hat vielleicht noch jemand eine Idee?

Viele Grüße,
DonKB

vince ·

ich hab mir Dein css mal näher angeschaut:

1) die css-Eingenschaften (margin und width) werden an anderer Stelle wieder überschrieben, z.B. hier

html, body, div, span, h1, h2, h3, h4, p, hr, table, tr ,td, th, a, ul, li, form, select, input, submit, label {
  margin:0; /* dadurch wird margin:auto nicht übernommen */
  padding:0;
  font-family:Verdana,Helvetica,Jamrul,sans-serif;
  color:#000000;
  font-size:11px;
}

bzw. hier:

html, body {
  height: 100%;
  width: 100%;
}

2) Viele der div-Container haben die Eigenschaft position:absolute, dadurch werden sie nicht relativ zur Position des bodys gesetzt.

mah ·

Im Endeffekt würde ich das niemals über Body lösen 🙂 Wofür hast du das div mit der id wrapper-content?
Genau um den Inhalt deiner Seite zum umschließen 😉
Also passt du einfach das CSS für diesen Container an.
#wrapper_content {
position:relative;
margin: 0 auto;
width: 950px;
}

Allerdings würde ich dir empfehlen dich damit mehr auseinander zu setzten, da der Rest deines CSS-Codes auch nicht wirklich "gut" ist. Wozu zum Beispiel floatet der Container #middle?

http://www.w3schools.com/ <-- Da gibt es einige Toturials

DonKB ·

Liebe Typo3-Freunde,

ich muss mich bei allen von euch herzlich bedanken.
Es hat geklappt und ich habe es über #wrapper_content endlich geschafft die Seite zu zentrieren.
Bestimmt lässt die nächste Frage nicht lange auf sich warten ...
Vielen, vielen Dank.

Gruss, DonKB 😃