Table/Div: want max width but no minimum

  • Thread starter HoustonFreeways
  • Start date
H

HoustonFreeways

I want to be able to set a maximum width on a block of text - say 600
pixels.

If the browser is larger, the text area is 600 pixels wide.

If the browser size is smaller than 600 pixels, I want the text area to
dynamically resize to the browser width and I don't want a scrollbar. This
is the behavior you get if you set table width to 100%, but of course if you
do that then there is no 600 pixel limit on the width. Setting table width
to 600px or DIV width to 600px causes scrollbar behavior when the browser is
less than 600 px wide.

I've experimented with tables and DIV blocks (overflow style), but no luck.

The reason I want this is for pop-up help screens.

Can this be done?
 
J

Jim Roberts

HoustonFreeways said:
I want to be able to set a maximum width on a block of text - say 600
pixels.

If the browser is larger, the text area is 600 pixels wide.

If the browser size is smaller than 600 pixels, I want the text area to
dynamically resize to the browser width and I don't want a scrollbar. This
is the behavior you get if you set table width to 100%, but of course if you
do that then there is no 600 pixel limit on the width. Setting table width
to 600px or DIV width to 600px causes scrollbar behavior when the browser is
less than 600 px wide.

in your stylesheet:

#div.content {
max-width: 600px;
}

html:
<div class="content">
...
</div>

Regards,
Jim Roberts
 
H

HoustonFreeways

Thanks guys for the link. The max-width style is exactly what I'm looking
for, and that workaround should get the job done until Microsoft implements
it.
 
B

Barry Pearson

HoustonFreeways said:
I want to be able to set a maximum width on a block of text - say 600
pixels.
[snip]

The simplest workaround I know is to use a single-cell table. Set "width" (not
max-width) on the cell (not the table).

<table>
<tr>
<td id="cell">Content here</td>
</tr>
</table>

#cell {
width: 400px;
}

The HTML (4.01 Strict) & CSS validate at W3C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top