• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

Automatische Div-Breite

dkdenz

New member
Hola.
Entweder bin ich zu blöd oder es geht einfach nicht.
Habe mir schon eine ganze Weile den Kopf zerbrochen, aber ich komme nicht drauf.
Ich möchte erreichen, das die Überschrift im div die Breite des div bestimmt.
Mache ich keine Angabe zu width, ist es automatisch 100% breit.
Mache ich eine minimale Angabe, läuft die h1 über das div hinaus und bricht auch noch um.
Weiß wer was?
Code:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<title>Dokumenttitel</title>
<style type="text/css">
/*<![CDATA[*/
html, body, div, span, p, h1, h2, h3, ul, li, a, acronym, cite, table, tr, td, form, label, input, img {
  font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
  font-size:14px;
  line-height:20px;
  color:#000;
  margin:0px;
  padding:0px;
  border:0px;
}
body {
  text-align:center;
}
#container {
  margin:0px auto;
  text-align:center;
}
h1 {
  border:1px solid #cacaca;
  padding:10px;
}
/*]]>*/
</style>
</head>
<body>
<div id="container"><h1>Ich bin eine Überschrift</h1></div>
</body>
</html>
 
Moin!

Da wirste wohl kaum um display:inline drumrumkommen. :(

Ahoi - Pit
 
ein stück weiter gedacht...

wie bekommt man die automatische div-breite hin wenn man ein bild drinnen hat?

mit dem css-befehl display:table; schafft man es für den ff.

... aber WIE für den ie?
 
Code:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
	<head>
		<title>Dokumenttitel</title>
		<style type="text/css">
			/*<![CDATA[*/
				     html, body, div, span, p, h1, h2, h3, ul, li, a, acronym, cite, table, tr, td, form, label, input, img {
				     font-family: 'Lucida Grande', Verdana, Geneva, Lucida, Arial, Helvetica, sans-serif;
				     font-size:14px;
				     line-height:20px;
				     color:#000;
				     margin:0px;
				     padding:0px;
				     border:0px;
				     }
				     body {
				     text-align:center;
				     }
				     #container {
				     margin:0px auto;
				     text-align:center;
				     }
				     img {
				     border:1px solid #cacaca;
				     padding:10px;
				     }
				     /*]]>*/
		</style>
	</head>
	<body>
		<div id="container"><img src="" alt="" width="250" height="200" /></div>
	</body>
</html>
 
Zuletzt bearbeitet:
Zurück
Oben