Probleme mit zentriertem 3-spaltigem Layout, wo Contentbereich gescrollt werden soll!

Status
Nicht offen für weitere Antworten.

Marokaner

Mitglied
Hallo!

Ich versuche schon seit einer halben Ewigkeit an einem Layout mit folgenden Eigenschaften herum zu basteln:
Header (gesamte Bildschirmbreite) und Footer (960 Pixel zentriert) machen keine Probleme.
Probleme bereitet mir der 3-spaltige Mittelteil. Der Mittelteil soll 960 Pixel breit und zentriert sein. Die Linke hat eine fixe Breite von 170 Pixeln, die rechte 120. Bleiben noch 670 Pixel für den Inhaltsbereich.

Das ganze soll so aussehen wie in der angehängten Grafik!

Mein Problem ist jetzt, dass der Inhaltsbereich (und NUR der Inhaltsbereich scrollbar sein soll) Der Rest soll fix bleiben. Wie realisiere ich das in CSS, damit es sowohl im IE, als auch in den anderen Browsern funktioniert. Eine Lösung für Firefox habe ich! Beim IE bin ich ratlos.
Vielleicht kann mir hier jemand helfen!

Hier mein CSS-Code für den IE: Ich bekomme die Scrollleiste nicht hin!

PHP:
<!-- Put IE into quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Layout 5</title>
<meta name="Author" content="Stu Nicholls" />
<style type="text/css">

/* the bit that does the work */

body {
  background:#CCCCCC;
  margin:0;
  border:0;
  padding:0;
  height:100%; 
  max-height:100%; 
  overflow: hidden; 
  text-align:center;
  }

/* for internet explorer */
* html body {
  padding:130px 0 20px 0; 
  }

#contentcontainer {
  position:fixed; 
  float:left;
  overflow:auto;
  text-align:left;
  width: 670px;
  background-image:url(Inhalt.jpg); 
  background-repeat:repeat; 
  background-position: -150px 0px;
  background-attachment:fixed;
  z-index:5;
  }

* html #contentcontainer {
  height:100%; 
  width:670px; 
   z-index:5;
  }

  
 #maincontainer {
	position:absolute;
	top:130px;
	bottom:20px;  
	background:brown;
	margin-left:-480px;
	width: 960px;
	z-index:3;
	overflow:hidden;
	}	 
  
* html #maincontainer {
  height:100%; 
  width:960px; 
  z-index:3;
  }
  
  
#content{
	width:100%;
	overflow:auto;
	}  	
	
#links{
	 float:left;
	 overflow:hidden;
	 width:170px; 
	 background:yellow;
	 z-index:3;
	 }	 
	 
	 
#rechts {
	float:right;
	overflow:hidden;
	width:120px;
	background:beige;
	z-index:3;
	}  
  
  
#header {
  position:absolute; 
  top:0; 
  left:0; 
  width:100%; 
  height:130px; 
  overflow:auto; 
  background:blue;
  }
* html #header {height:130px;}


#footer {
  position:absolute; 
  bottom:0; 
  width:960px
  height:20px; 
  overflow:hidden; 
  text-align:right; 
  background:red;
  z-index:10;
  }
  
* html #footer {
	height:20px;  
	width:960px;
	margin-left:-480px;
}


</style>
</head>
<body>

<div id="maincontainer">
	<div id="links">links</div>
	<div id="contentcontainer">
		<div id="content">
		<p>
		Inhalt: falls overflow erscheint die scrollbar jedoch nicht!
		</p>
	</div>
	</div>
	<div id="rechts">rechts</div>
</div>

<div id="header">Header</div>
<div id="footer">Footer</div>

</body>
</html>
 

Anhänge

  • Layout.jpg
    Layout.jpg
    36,8 KB · Aufrufe: 29
Weshalb schickst du denn den IE in den Quirksmode, wenn du anschließend wieder Spezialangaben für ihn verwendest?
Die bräuchstest du dann konsequenter Weise auch für den IE 7.
Also würde ich zunächst den Quirksmode und sämtliche * html entfernen.

Hilft dir vielleicht dieses Beispiel weiter?

Damit die Scrollbar erscheint musst du "overflow: scroll;" nehmen.
 
Ich habe mal was gebastelt. Ist für den Scrollbereich mit einer "Krückenlösung", sollte aber funktionieren:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Layout 5</title>
<meta name="Author" content="Stu Nicholls" />
<style type="text/css">

/* the bit that does the work */

html
{
height: 100%;
}

body
{
height: 100%;
width: 100%;
margin: 0;
padding: 0;
background: #ccc;
font-family: Verdana, Arial, sans-serif;
}

 #maincontainer {

margin:0 auto 20px auto;
    background:brown;
    width: 960px;
height: 100%;
    z-index:-1;

    }



#content
{
overflow: scroll;
height: 50%;
margin-left: 170px;
background: #B384A7;
padding-bottom: 2000px;
}



#links
{
float: left;

width: 170px;
background: yellow;
padding-bottom: 20px;
}

#rechts {
    float:right;
    overflow:hidden;
    width:120px;
    background:beige;

	padding-bottom: 20px;
    }


#header {
  width:100%;
  height:130px;
  overflow:auto;
  background:blue;
  }



#footer {
  position:absolute;
  bottom:0;
  width:960px;
  height:20px;
  overflow:hidden;
  text-align:right;
  background:red;
  z-index:10;
  }

#wrapper {
height: 100%;
overflow:hidden;
}

</style>
</head>
<body>
<div id="wrapper">
	<div id="header">Header</div>

			<div id="maincontainer">
			    <div id="links">links</div>


 					   <div id="rechts">rechts</div>

							<div id="content">
							<h1>Anfang</h1>
        <p>
        Inhalt: falls overflow erscheint die scrollbar jedoch nicht!
        </p>
 			<p>
        Inhalt: falls overflow erscheint die scrollbar jedoch nicht!
        </p>
        <p>
        Inhalt: falls overflow erscheint die scrollbar jedoch nicht!
        </p>

        <h1>Ende</h1>
  </div> <!--Ende #content-->
<div id="footer">Footer</div>


</div><!--Ende #maincontainer-->
</div><!--Ende #wrapper"-->

</body>
</html>
 
Hi,

ich hätte da auch noch einen Vorschlag:
Code:
<!-- Put IE into quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>www.tutorials.de</title>
<meta name="Author" content="Quaese" />
<style type="text/css">

*{ margin: 0;
   padding: 0;}

body, html{ height: 100%;}

body { background: #ccc;
       border: 0;
       overflow: hidden;
       text-align: center;}

#maincontainer{ position: relative;
                width: 100%;
                height: 100%;
                text-align: left;}


#header{ position: absolute;
         top: 0;
         height: 130px;
         width: 100%;
         z-index: 5;
         background: #f00;}

#links{ position: absolute;
        top: 130px;
        bottom: 20px;
        left: 50%;
        margin-left: -480px; /* 960:2 */
        width: 170px;
        background: #f0f;}

#rechts{ position: absolute;
         top: 130px;
         bottom: 20px;
         left: 50%;
         margin-left: 360px; /* 960:2 - 120 */
         width: 120px;
         background: #0ff;}

#contentcontainer{ position: absolute;
                   top: 130px;
                   bottom: 20px;
                   left: 50%;
                   margin-left: -310px;
                   width: 670px;
                   background: #fff;
                   overflow: auto;}

#footer{ position: absolute;
         bottom: 0;
         left: 50%;
         margin-left: -480px;
         height: 20px;
         width: 960px;
         z-index: 5;
         background: #ff0;}
</style>
<!--[if IE]>
<style type="text/css">

#links{ position: relatvie;
        top: 0;
        left: 50%;
        margin-left: -480px; /* 960:2 */
        width: 170px;
        height: 100%;
        padding: 130px 0 20px 0;
        background: #f0f;}

#rechts{ position: relatvie;
         top: 0;
         left: 50%;
         margin-left: 360px; /* 960:2 - 120 */
         width: 120px;
         height: 100%;
         padding: 130px 0 20px 0;
         background: #0ff;}

#contentcontainer{ position: relatvie;
                   top: 0;
                   left: 50%;
                   margin-left: -310px;
                   width: 670px;
                   background: #fff;
                   height: 100%;
                   border-width: 130px 0 20px 0;
                   border-style: solid;
                   border-color: #fff;
                   overflow: auto;}

#footer{ bottom: -1px;}
</style>
<![endif]-->
</head>
<body>
<div id="maincontainer">
  <div id="header">Header</div>

  <div id="links">links</div>
  <div id="contentcontainer">
    <div id="content" style="height: 2000px;">
      <p>
        Inhalt: falls overflow erscheint die scrollbar jedoch nicht!
      </p>
   </div>
  </div>
  <div id="rechts">rechts</div>

  <div id="footer">Footer</div>
</div>
</body>
</html>
Ciao
Quaese
 
@ Quaese:
Also deine Lösung ist wirklich sehr intelligent! Und ich hab's sogar verstanden :)
Danke nochmals!

Nur jetzt hab ich ein anderes Problem. Ich möchte die CSS-Datei natürlich auslagern.
Was muss ich dafür ändern? Kann ich das überhaupt in EINE Datei auslagern oder brauche ich zwei verschiedene CSS-Dateien? Eine für den IE und eine für die anderen Browser.

Hier mal meine bisherige CSS-Datei Layout.css:
PHP:
*{ margin: 0;
   padding: 0;}

body, html{ height: 100%;}

body { background: #ccc;
       border: 0;
       overflow: hidden;
       text-align: center;}

#maincontainer{ position: relative;
                width: 100%;
                height: 100%;
                text-align: left;}


#header{ position: absolute;
         top: 0;
         height: 130px;
         width: 100%;
         z-index: 5;
         background: #f00;}

#links{ position: absolute;
        top: 130px;
        bottom: 20px;
        left: 50%;
        margin-left: -480px; /* 960:2 */
        width: 170px;
        background: #f0f;}

#rechts{ position: absolute;
         top: 130px;
         bottom: 0px;
         left: 50%;
         margin-left: 360px; /* 960:2 - 120 */
         width: 120px;
         background: #0ff;}

#contentcontainer{ position: absolute;
                   top: 130px;
                   bottom: 20px;
                   left: 50%;
                   margin-left: -310px;
                   width: 670px;
                   background: #fff;
                   overflow: auto;}
                            
#content{
	margin:20px;
}

#footer{ position: absolute;
         bottom: 0;
         left: 50%;
         margin-left: -480px;
         height: 20px;
         width: 840px;
         z-index: 5;
         background: #ff0;}

         
   /* nur für IE */    
   /* wenn ich die Angaben ab hier weg lasse funktioniert es wenigstens im Firefox und Opera */
         
* #links{ position: absolute;
        top: 0;
        left: 50%;
        margin-left: -480px; /* 960:2 */
        width: 170px;
        height: 100%;
        padding: 130px 0 20px 0;
        background: #f0f;}

* #rechts{ position: absolute;
         top: 0;
         left: 50%;
         margin-left: 360px; /* 960:2 - 120 */
         width: 120px;
         height: 100%;
         padding: 130px 0 0 0;
         background: #0ff;}

* #contentcontainer{ position: absolute;
                   top: 0;
                   left: 50%;
                   margin-left: -310px;
                   width: 670px;
                   background: #fff;
                   height: 100%;
                   border-width: 130px 0 20px 0;
                   border-style: solid;
                   border-color: #fff;
                   overflow: auto;}

* #footer{ bottom: -1px;}

Kann ich das überhaupt so machen? Irgendwas muss noch falsch sein! Wie mach ich dem IE klar, welche Style-Angaben für ihn bestimmt sind? Ich hab das mit den * zwar schon mal gesehen, aber ich verstehe es ehrlich gesagt nicht! Kann mir das jemand bitte erklären!?
Und warum rutscht der scrollbare Bereich sogar im Firefox aus dem Bildschirm, sobald ich die zusätzlichen Angaben (siehe Layout.css) definiere?

Man ist das kompliziert!

Hier noch die tutorials.html von Quaese:
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>tutorials.de</title>
<meta name="Author" content="Quaese" />
<link rel="stylesheet" href="Layout.css">
</head>
<body>
<div id="maincontainer">
  <div id="header">Header</div>

  <div id="links">links</div>
  <div id="contentcontainer">
    <div id="content"style>
      <p>
        Inhalt: Probleme werden erst bei overflow sichtbar! 
       </p>
   </div>
  </div>
  <div id="rechts">rechts</div>

  <div id="footer">Footer</div>
</div>
</body>
</html>

Für Hilfe wäre ich dankbar!
 
Hi,

du musst zwei CSS-Dateien anlegen, eine für die IEs und eine für die sonstigen Browser.

Im Quelltext wird für die IE-Variante wieder ein conditional comment verwendet.
Code:
<!-- Put IE into quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>www.tutorials.de</title>
<meta name="Author" content="Quaese" />
<link rel="stylesheet" href="Layout.css">
<!--[if IE]>
<link rel="stylesheet" href="Layout_ie.css">
<![endif]-->
</head>
<body>
<div id="maincontainer">
  <div id="header">Header</div>

  <div id="links">links</div>
  <div id="contentcontainer">
    <div id="content" style="height: 2000px;">
      <p>
        Inhalt: falls overflow erscheint die scrollbar jedoch nicht!
      </p>
   </div>
  </div>
  <div id="rechts">rechts</div>

  <div id="footer">Footer</div>
</div>
</body>
</html>
Ciao
Quaese
 
Also, sorry wenn ich nerve! Aber ich blick des net! Wenn die Style-Angaben direkt im Header der HTML-Datei definiert sind (so wie im Lösungsvorschlag von Quaese) dann funktioniert es in allen Browsern. Wenn die Styles auslagere, dann habe ich im Internet Explorer wieder meine alten Probleme mit der Scrollleiste. Aber warum? Es muss doch funktionieren!?

Hier meine Layoutie.css
PHP:
*{ margin: 0;
   padding: 0;}

body, html{ height: 100%;}

body { background: #ccc;
       border: 0;
       overflow: hidden;
       text-align: center;}

#maincontainer{ position: relative;
                width: 100%;
                height: 100%;
                text-align: left;}


#header{ position: absolute;
         top: 0;
         height: 130px;
         width: 100%;
         z-index: 5;
         background: #f00;}

#links{ position: absolute;
        top: 130px;
        bottom: 20px;
        left: 50%;
        margin-left: -480px; /* 960:2 */
        width: 170px;
        background: #f0f;}

#rechts{ position: absolute;
         top: 130px;
         bottom: 0px;
         left: 50%;
         margin-left: 360px; /* 960:2 - 120 */
         width: 120px;
         background: #0ff;}

#contentcontainer{ position: absolute;
                   top: 130px;
                   bottom: 20px;
                   left: 50%;
                   margin-left: -310px;
                   width: 670px;
                   background: #fff;
                   overflow: auto;}
                            
#content{
	margin:20px;
}

#footer{ position: absolute;
         bottom: 0;
         left: 50%;
         margin-left: -480px;
         height: 20px;
         width: 840px;
         z-index: 5;
         background: #ff0;}

@ Quaese: Kann es sein, dass es was mit position-Angaben zu tun hat? Du hattest dich nämlich vertippt (bei den Angaben für den IE). Die relative Positonierung hat also nie funktionert.

Ich bin gespannt wann endlich alles klappt so wie ich mir das vorstelle! Wenn es im IE geht, geht's wahrscheinlich in den anderen Browsern nimmer!

Hilfe :eek:
 
Du kannst eine gesonderte CSS-Datei für den IE nehmen, ist aber m.E. nicht zwingend erforderlich. Allerdings etwas eleganter, weil man hier die IE-Spezialangaben gebündelt hat.

In welchem IE funktioniert es nicht?
Ich vermute, dass es im IE 6 funktioniert, jedoch nicht im IE 7.
Grund:
Die Speziealangaben für den IE 6 erfolgen mit dem vorangestellten Stern *
Für den IE 7 benötigt man dagegen Stern Plus, also *+
Somit müsstest du sämtliche Angaben, die mit einem Stern beginnen nochmals kopieren und das "+" hinter den Stern einfügen. (Wobei ich es nur mit "* html" oder "*+ html" kenne.)

Das sieht dann für dieses Element z.B. so aus:
Code:
* #links{ position: absolute;
        top: 0;
        left: 50%;
        margin-left: -480px; /* 960:2 */
        width: 170px;
        height: 100%;
        padding: 130px 0 20px 0;
        background: #f0f;} 

*+ #links{ position: absolute;
        top: 0;
        left: 50%;
        margin-left: -480px; /* 960:2 */
        width: 170px;
        height: 100%;
        padding: 130px 0 20px 0;
        background: #f0f;}

Diese Angaben sind m.E. jedoch nur deshalb nötig, weil ihr den IE in den Quirksmode geschickt habt.
Bei meinem Vorschlag (allerdings nicht im IE 6 getestet) bleibt der IE im Standardmode und sollte deshalb keine Spezialbehandlung erfordern.
 
Hi,

ich hab dir meinen Lösungsvorschlag mit externen CSS-Dateien in den Anhang gepackt.

@prm - hast du deinen Lösungsvorschlag mal im FF kleiner als Version 3 angesehen? Dort ist das Design bei mir verschoben.

Ciao
Quaese
 

Anhänge

  • layout.zip
    1,4 KB · Aufrufe: 21
Status
Nicht offen für weitere Antworten.
Zurück