parent und child div mit 100% höhe und padding

parent und child div mit 100% höhe und padding

Beitragvon usperry » 16.08.2010, 15:10

hi, ich bin am verzweifeln.
das padding wird unten nicht richtig abgebildet und der parent umgibt seine children nicht!!
hier ein beispiel:

Code: Alles auswählen
<html>
<head>
<style type="text/css">
head, body {height:100%;margin:0}
</style>
</head>

<body>

<div style="
min-height:100%;
height:auto;   
height:100%;
background:#FF0; /*yellow*/
padding:10px;">
this is the stage div! it doesn't want to wrap around his children!

  <div style="
  background-color: #F00; /*red*/
  width: 700px;
  min-height: 100%;
  height:100%;
  padding:20px;">
 
  this is the main content. padding on the bottom doesn't work.
 
    <div style="
    float:right;
    background-color: #0FF; /*blue*/
    width: 100px;
    min-height: 100%;
    height:100%;
    ">
   
    this ist a right aligned box, who wants to be 100% height
   
    </div>
    <div style="
    background-color: #0F0; /*green*/
    width:500px;
    height:700px;
    " >
    this is a box on the left, that has a fixed height
   
    </div>
   </div>
 
</div>
</body>
</html>

Der Dateianhang Untitled.jpg existiert nicht mehr.


kann mir jemand helfen? Ich benutze IE
Untitled.jpg
so siehts im browser aus
Untitled.jpg (11.29 KiB) 1206-mal betrachtet
usperry
neu hier
 
Beiträge: 4
Registriert: 16.08.2010, 14:46

Re: parent und child div mit 100% höhe und padding

Beitragvon Azra » 16.08.2010, 15:19

“HTML is the language for describing the structure of Web pages.”
“CSS is the language for describing the presentation of Web pages, including colors, layout, and fonts.”
Noch weitere Probleme? Kontakt über meine Webseite - simonduda.ch
Benutzeravatar
Azra
Stammuser
 
Beiträge: 422
Registriert: 04.02.2010, 08:36
Wohnort: (Alten)bochum

Re: parent und child div mit 100% höhe und padding

Beitragvon usperry » 17.08.2010, 06:15

tut mir leid, den doctype hab ich raus gelassen um den code so kurz wie möglich zu halten. der Doytype ist:

Code: Alles auswählen
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
usperry
neu hier
 
Beiträge: 4
Registriert: 16.08.2010, 14:46

Re: parent und child div mit 100% höhe und padding

Beitragvon usperry » 17.08.2010, 06:53

also, jetzt habe ich den code nochmal etwas angepasst. hinzu kommt eine background-farbe für den body. nun scheint das padding zu funktionieren, aber trotzdem expandieren die divs nicht auf 100%. Hat jemand eine Lösung?

Code: Alles auswählen
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unbenanntes Dokument</title>

<style type="text/css">

head, body {height:100%;margin:0;background:#999} <!--GRAY-->

</style>
</head>

<body>

<div style="
min-height: 100%;
height:auto !important;
background:#FF0; /*YELLOW*/
padding:10px;">
this is the stage div! it wants to be 100% height!

  <div style="
  background-color: #F00; /*RED*/
  min-height: 100%;
  height:100%;
  width: 700px;
  padding:20px;">
 
  this is the main content. Also wants to be 100% height.
 
    <div style="
    float:right;
    min-height: 100%;
    height:100%;
    background-color: #0FF; /*BLUE*/
    width: 100px;
    ">
   
    this ist a right aligned div, who wants to be 100% height, but is just a smal box
   
    </div>
   
    <div style="
    background-color: #0F0; /*GREEN*/
    width:500px;
    height:300px;
    " >
    this is a box on the left, that has a fixed height! This works! :)
   
    </div>
   </div>
 
</div>

</body>
</html>

Dateianhänge
Untitled.jpg
so sieht das bild im browser aus
Untitled.jpg (28.86 KiB) 1184-mal betrachtet
usperry
neu hier
 
Beiträge: 4
Registriert: 16.08.2010, 14:46

Re: parent und child div mit 100% höhe und padding

Beitragvon Azra » 17.08.2010, 06:59

Also bei mir sieht es im IE8 wie folgt aus:


Dafür stimmt im Firefox hinten und vorne etwas nicht.
Also dem roten sowie gelben Container musst du lediglich "height: auto;" verpassen (der gelbe Container verfügt über doppelte Werte), dann sieht es meines Erachtens in Firefox und IE8 gut aus.
Die anderen Browserversionen kann ich leider nicht überprüfen.
“HTML is the language for describing the structure of Web pages.”
“CSS is the language for describing the presentation of Web pages, including colors, layout, and fonts.”
Noch weitere Probleme? Kontakt über meine Webseite - simonduda.ch
Benutzeravatar
Azra
Stammuser
 
Beiträge: 422
Registriert: 04.02.2010, 08:36
Wohnort: (Alten)bochum

Re: parent und child div mit 100% höhe und padding

Beitragvon usperry » 17.08.2010, 09:14

danke azra, ich habe jetzt eine etwas andere Lösung gefunden und zwar mußte ich position:absolute einbauen (in kombination von top, bottom, right and left)... hier mein code der jetzt funktioniert:

Code: Alles auswählen
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Unbenanntes Dokument</title>

<style type="text/css">

body {height:100%;margin:0;background:#999} <!--GRAY-->

</style>
</head>

<body>

<div style="
position:absolute;
top:0;
bottom:0;
height: 100%;
background:#FF0; /*YELLOW*/
padding:10px;
width:100%">
this is the stage div! it is now 100% height!

<div style="
  position:absolute;
  top:0;
  bottom:0;
  height: 100%;
  height:auto;
  width: 700px;
  background-color: #F00; /*RED*/
  padding:20px;">
 
  this is the main content. Also is 100% height now.
 
  <div style="
    float:right;
    min-height: 100%;
    height:100%;
    background-color: #0FF; /*BLUE*/
    width: 100px;
    ">
   
    this ist a right aligned div, who now is 100% height
   
    </div>
   
    <div style="
    background-color: #0F0; /*GREEN*/
    width:500px;
    height:300px;
    " >
    this is a box on the left, that has a fixed height! This works! :)
   
    </div>
 
  </div>
</div>

</body>
</html>
usperry
neu hier
 
Beiträge: 4
Registriert: 16.08.2010, 14:46


Moderatoren: Laus, Moderatoren

Ähnliche Beiträge zu "parent und child div mit 100% höhe und padding"

Zurück zu: CSS für Fortgeschrittene

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast