Hi all,
If I have a <DIV> with elements contained in it, how can I get the <DIV> to just be the height, and if possible, the width to be as high and wide as the <DIV>s containing elements?
Thanks
Tryst
Printable View
Hi all,
If I have a <DIV> with elements contained in it, how can I get the <DIV> to just be the height, and if possible, the width to be as high and wide as the <DIV>s containing elements?
Thanks
Tryst
Hmmm,
Can you run that by me again lol :)
I'm not quite sure what you are asking but a div with no height specified (height:auto) will be as high as the content requires. The same goes for width except that if you have a border it will be 100% wide.
Perhaps thats what you mean :)
The only way I can think of is when you make the parent absolute and then it collapses to fit the content (but of course it causes other display issues).
PaulCode:<!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">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
#outer{
border:1px solid red;
position:absolute;
}
</style>
</head>
<body>
<div id="outer"><p>Hello this is some text</p></div>
</body>
</html>
What I have at the moment is a <DIV> which just contains a few input textboxes. But when I set the background colour of the <DIV> it takes up around 80% of the screen for some reason.
NO no, sorry, my mistake. I was compeletly screwing things up in my CSS. You are right, its just I had a hidden statement in my CSS which making the <DIV> pretty huge :)
Thanks
Tryst