Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| ...
* html #mitte {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-top-width: 150px; /* = Kopfzeilenhöhe */
border-left-width: 200px; /* = Spaltenbreite links */
border-bottom-width: 50px; /* = Fußzeilenhöhe */
border-right-width: 100px; /* = Spaltenbreite rechts */
border-style: solid;
... /* tiefste z-Ebene! */
}
...
* html #oben {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 150px;
z-index: 4; /* höchste z-Ebene */
}
...
* html #links {
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 100%;
border-top-width: 150px; /* = Kopfzeilenhöhe */
border-left-width: 0;
border-bottom-width: 0;
border-right-width: 0;
border-style: solid;
z-index: 3;
}
...
* html #unten {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 50px;
border-top-width: 0;
border-left-width: 200px; /* = Spaltenbreite links */
border-bottom-width: 0;
border-right-width: 0;
border-style: solid;
z-index: 2;
}
...
* html #rechts {
position: absolute;
top: 0;
right: 0;
width: 100px;
height: 100%;
border-top-width: 150px; /* = Kopfzeilenhöhe */
border-left-width: 0;
border-bottom-width: 50px; /* = Fußzeilenhöhe */
border-right-width: 0;
border-style: solid;
z-index: 1;
}
... |
Die Reihenfolge des Index für die z-Ebenen ist vom Layout abhängig und aus dem obenstehenden Bild ersichtlich. Die Werte des z-Index wurden im Beispiel zwischen 1 und 4 gewählt und können bei Einhaltung der Reihenfolge beliebig geändert werden.
Die IE-spezifischen Selektoren werden in die Stylesheets für alle anderen Browser nach den entsprechenden Selektoren eingefügt und anschließend können alle doppelt vorkommenden Eigenschaften mit gleichen Werten in den IE-spezifischen Selektoren gelöscht werden. Ebenso ist es sinnvoll, die z-Index-Eigenschaften in die für alle Browser gültigen Selektoren zu verlegen.
Komplett ist alles in Beispiel 2 zu finden.
Noch mal: Diese Realisierungsmöglichkeit funktioniert im Internet-Explorer nur dann, wenn der IE über die Dokumenttyp-Deklaration in den Quirksmode gesetzt wird. Derzeit also bei beispielsweise folgenden DOCTYPE-Angaben:
- ohne DOCTYPE-Angaben
- HTML 4.01 Transitionlal ohne URI: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- XML + XHTML 1.0 Transitional: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
- XML + XHTML 1.0 Transitional + URI: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- XML + XHTML 1.0 Strict: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">
- XML + XHTML 1.0 Strict + URI: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Eine umfassende Übersicht zum Zusammenhang zwischen Dokumenttyp-Deklaration und Darstellungsmodus verschiedener Browser ist in iX 3/2004 zu finden.
Letztendlich soll noch ein Nachteil dieser Methode nicht verschwiegen werden:
Da einerseits der mittlere Block eine Gesamtbreite und -höhe von 100% hat und somit den gesamten Bildschirm abdeckt und andererseits der Internet-Explorer keine transparenten Rahmen unterstützt, ist hier die Darstellung einer zusammenhängenden Hintergrundgrafik im BODY für alle Blöcke nicht möglich. Mit etwas Aufwand kann man das umgehen, indem das Hintergrundbild entsprechend der sichtbaren Größe der einzelnen Blöcke geteilt und die Teilbilder den entsprechenden Blöcken als separates Hintergrundbild zugewiesen wird.
Anhang
Beispiel 1 (Quelltext)
HTML-Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS-Beispiel 1: position_fixed</title>
<style type="text/css">
<!--
html, body {
width: 100%;
height: 100%;
margin: 0;
border: 0;
padding: 0;
}
body {
background-color: #fff;
overflow: hidden; /* Scrollbalken im Fenster unterbinden */
}
#mitte {
position: absolute;
top: 150px; /* Abstand zum oberen Fensterrand */
left: 200px; /* Abstand zum linken Fensterrand */
bottom: 50px; /* Abstand zum unteren Fensterrand */
right: 100px; /* Abstand zum rechten Fensterrand */
overflow: auto; /* Scrollbalken, falls notwendig */
/* nur für IE: */
width: expression((document.body.clientWidth - 300) + "px");
/* left-Wert + right-Wert = 300 */
height: expression((document.body.clientHeight - 200) + "px");
/* top-Wert + bottom-Wert = 200 */
}
#mitte .inhaltDiv {
margin: 20px; /* Abstand des Inhalts zum Blockrand */
}
#oben {
position: absolute;
top: 0; /* Abstand zum oberen Fensterrand */
left: 0; /* Abstand zum linken Fensterrand */
right: 0; /* Abstand zum rechten Fensterrand */
height: 150px; /* Blockhöhe */
padding: 0; /* Interpretation Boxmodell! */
background-color: #cfc;
overflow: hidden; /* Scrollbalken unterbinden */
/* nur für IE: */
width: expression(document.body.clientWidth + "px");
/* left-Wert + right-Wert = 0 */
}
#oben .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
#links {
position: absolute;
top: 150px; /* Abstand zum oberen Fensterrand */
left: 0; /* Abstand zum linken Fensterrand */
bottom: 0; /* Abstand zum unteren Fensterrand */
width: 200px; /* Blockbreite */
padding: 0; /* Interpretation Boxmodell! */
background-color: #ffc;
overflow: auto; /* Scrollbalken, falls notwendig */
/* nur für IE: */
height: expression((document.body.clientHeight - 150) + "px");
/* top-Wert + bottom-Wert = 150 */
}
#links .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
#unten {
position: absolute;
left: 200px; /* Abstand zum linken Fensterrand */
bottom: 0 !important; /* Abstand zum unteren Fensterrand */
bottom: -1px; /* nur für IE */
right: 0; /* Abstand zum rechten Fensterrand */
height: 50px; /* Blockhöhe */
padding: 0; /* Interpretation Boxmodell! */
background-color: #fcf;
overflow: hidden; /* Scrollbalken unterbinden */
/* nur für IE: */
width: expression((document.body.clientWidth - 200) + "px");
/* left-Wert + right-Wert = 200 */
}
#unten .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
#rechts {
position: absolute;
top: 150px; /* Abstand zum oberen Fensterrand */
bottom: 50px; /* Abstand zum unteren Fensterrand */
right: 0; /* Abstand zum rechten Fensterrand */
width: 100px; /* Blockbreite */
padding: 0; /* Interpretation Boxmodell! */
background-color: #ccf;
overflow: hidden; /* Scrollbalken unterbinden */
/* nur für IE: */
height: expression((document.body.clientHeight - 200) + "px");
/* top-Wert + bottom-Wert = 200 */
}
#rechts .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
-->
</style>
</head>
<body>
<div id="mitte"><div class="inhaltDiv">
<h1>#mitte:</h1>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ...
</p>
</div></div>
<div id="oben"><div class="inhaltDiv">
<h2>#oben</h2>
</div></div>
<div id="links"><div class="inhaltDiv">
<h2>#links:</h2>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ...
</p>
</div></div>
<div id="rechts"><div class="inhaltDiv">
<h2>#rechts:</h2>
<p>
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcor ...
</p>
</div></div>
<div id="unten"><div class="inhaltDiv">
<h2>#unten</h2>
</div></div>
</body>
</html>
Beispiel 2 (Quelltext)
HTML-Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!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">
<head>
<title>CSS-Beispiel 2: position_fixed</title>
<style type="text/css">
<!--
html, body {
width: 100%;
height: 100%;
margin: 0;
border: 0;
padding: 0;
}
body {
background-color: #fff;
overflow: hidden; /* Scrollbalken im Fenster unterbinden */
}
#mitte {
position: absolute;
top: 150px; /* Abstand zum oberen Fensterrand */
left: 200px; /* Abstand zum linken Fensterrand */
bottom: 50px; /* Abstand zum unteren Fensterrand */
right: 100px; /* Abstand zum rechten Fensterrand */
overflow: auto; /* Scrollbalken, falls notwendig */
}
* html #mitte {
top: 0;
left: 0;
width: 100%;
height: 100%;
border-top-width: 150px; /* = Kopfzeilenhöhe */
border-left-width: 200px; /* = Spaltenbreite links */
border-bottom-width: 50px; /* = Fußzeilenhöhe */
border-right-width: 100px; /* = Spaltenbreite rechts */
border-style: solid;
}
#mitte .inhaltDiv {
margin: 20px; /* Abstand des Inhalts zum Blockrand */
}
#oben {
position: absolute;
top: 0; /* Abstand zum oberen Fensterrand */
left: 0; /* Abstand zum linken Fensterrand */
right: 0; /* Abstand zum rechten Fensterrand */
height: 150px; /* Blockhöhe */
padding: 0; /* Interpretation Boxmodell! */
background-color: #cfc;
overflow: hidden; /* Scrollbalken unterbinden */
z-index: 4; /* höchste z-Ebene! */
}
* html #oben {
width: 100%;
height: 150px;
}
#oben .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
#links {
position: absolute;
top: 150px; /* Abstand zum oberen Fensterrand */
left: 0; /* Abstand zum linken Fensterrand */
bottom: 0; /* Abstand zum unteren Fensterrand */
width: 200px; /* Blockbreite */
padding: 0; /* Interpretation Boxmodell! */
background-color: #ffc;
overflow: auto; /* Scrollbalken, falls notwendig */
z-index: 3;
}
* html #links {
top: 0;
width: 200px;
height: 100%;
border-top-width: 150px; /* = Kopfzeilenhöhe */
border-left-width: 0;
border-bottom-width: 0;
border-right-width: 0;
border-style: solid;
}
#links .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
#unten {
position: absolute;
left: 200px; /* Abstand zum linken Fensterrand */
bottom: 0; /* Abstand zum unteren Fensterrand */
right: 0; /* Abstand zum rechten Fensterrand */
height: 50px; /* Blockhöhe */
padding: 0; /* Interpretation Boxmodell! */
background-color: #fcf;
overflow: hidden; /* Scrollbalken unterbinden */
z-index: 2;
}
* html #unten {
left: 0;
width: 100%;
height: 50px;
border-top-width: 0;
border-left-width: 200px; /* = Spaltenbreite links */
border-bottom-width: 0;
border-right-width: 0;
border-style: solid;
}
#unten .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
#rechts {
position: absolute;
top: 150px; /* Abstand zum oberen Fensterrand */
bottom: 50px; /* Abstand zum unteren Fensterrand */
right: 0; /* Abstand zum rechten Fensterrand */
width: 100px; /* Blockbreite */
padding: 0; /* Interpretation Boxmodell! */
background-color: #ccf;
overflow: hidden; /* Scrollbalken unterbinden */
z-index: 1;
}
* html #rechts {
top: 0;
width: 100px;
height: 100%;
border-top-width: 150px; /* = Kopfzeilenhöhe */
border-left-width: 0;
border-bottom-width: 50px; /* = Fußzeilenhöhe */
border-right-width: 0;
border-style: solid;
}
#rechts .inhaltDiv {
margin: 10px; /* Abstand des Inhalts zum Blockrand */
}
-->
</style>
</head>
<body>
<div id="mitte"><div class="inhaltDiv">
<h1>#mitte:</h1>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ...
</p>
</div></div>
<div id="oben"><div class="inhaltDiv">
<h2>#oben</h2>
</div></div>
<div id="links"><div class="inhaltDiv">
<h2>#links:</h2>
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam ...
</p>
</div></div>
<div id="rechts"><div class="inhaltDiv">
<h2>#rechts:</h2>
<p>
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcor ...
</p>
</div></div>
<div id="unten"><div class="inhaltDiv">
<h2>#unten</h2>
</div></div>
</body>
</html>
Beispieldateien und das Tutorial als HTML-Datei im Anhang
Lesezeichen