Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > make a div use maximum width

Reply
Thread Tools

make a div use maximum width

 
 
Gernot Frisch
Guest
Posts: n/a
 
      08-21-2007

Hi,
I want the green piece ("Please be wide") to fill the whole space
between the red and the blue thingy. How can I do that?

Thank you in advice,
-Gernot

PS: My code is as minimal as possible, I know I should use strict-html
and stuff.


<html>
<body>
<div style="width:50%;">
<!-- left item -->
<div style="float:left; width:16px; background-color:Red;"></div>

<!-- center text -->
<div style="float:left; background-color:green;">Please be wide</div>
<!-- right item -->
<div style="float:right; width:16px; background-color:blue;"></div>
</div>
</body>
</html>




 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      08-21-2007
Well bust mah britches and call me cheeky, on Tue, 21 Aug 2007 08:49:07 GMT
Gernot Frisch scribed:

>
> Hi,
> I want the green piece ("Please be wide") to fill the whole space
> between the red and the blue thingy. How can I do that?
>
> Thank you in advice,
> -Gernot
>
> PS: My code is as minimal as possible, I know I should use strict-html
> and stuff.
>
>
> <html>
> <body>
> <div style="width:50%;">
> <!-- left item -->
> <div style="float:left; width:16px; background-color:Red;"></div>
>
> <!-- center text -->
> <div style="float:left; background-color:green;">Please be wide</div>
> <!-- right item -->
> <div style="float:right; width:16px; background-color:blue;"></div>
> </div>
> </body>
> </html>


Put a &nbsp; after <div style="width:50%;">

--
Neredbojias
Half lies are worth twice as much as whole lies.
 
Reply With Quote
 
 
 
 
Gernot Frisch
Guest
Posts: n/a
 
      08-21-2007

>
> Put a &nbsp; after <div style="width:50%;">


No. Neither in IE6, nor in FF.


 
Reply With Quote
 
Martin Jay
Guest
Posts: n/a
 
      08-22-2007
On Tue, 21 Aug 2007 10:49:07 +0200, "Gernot Frisch" <>
wrote:
>I want the green piece ("Please be wide") to fill the whole space
>between the red and the blue thingy. How can I do that?


This is because the centre DIV isn't given a width.

><html>
><body>
><div style="width:50%;">
> <!-- left item -->
> <div style="float:left; width:16px; background-color:Red;"></div>
>
> <!-- center text -->
> <div style="float:left; background-color:green;">Please be wide</div>
> <!-- right item -->
> <div style="float:right; width:16px; background-color:blue;"></div>
></div>
></body>
></html>


One solution may be to wrap the left, centre and right DIVs into an
additional DIV, and give that a green background colour:

<html>
<body>
<div style="width:50%;">

<div style="background-color: green; float: left;">

<!-- left item -->
<div style="float:left; width:16px; background-color:Red;"></div>
<!-- center text -->
<div style="float:left; background-color:green;">Please be wide</div>
<!-- right item -->
<div style="float:right; width:16px; background-color:blue;"></div>
</div>

</div>

</body>
</html>
--
Martin Jay
 
Reply With Quote
 
Gernot Frisch
Guest
Posts: n/a
 
      08-22-2007

> One solution may be to wrap the left, centre and right DIVs into an
> additional DIV, and give that a green background colour:


Perfect! That's the way to do it.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<div ... /> and <div ...></div> K Viltersten ASP .Net 4 03-31-2009 07:33 PM
two div in one line, first div's width is const and the second isn't tomek milewski HTML 6 06-25-2007 09:28 PM
set div width to remaining width of the browser Steve Richter ASP .Net 2 06-15-2007 06:40 PM
how to: div width = browser.width? =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 3 10-30-2006 05:43 AM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM



Advertisments
 



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