By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,846 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,846 IT Pros & Developers. It's quick & easy.

Autosize div?

P: n/a
Hi!

I want a div to have width:10em if the content
is narrow enough, but size it (not line-break),
when the content will become longer.

How can I do this?

Thank you,
Paul

Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Paul Rohorzka <da*********************@softconcept.atdasauch> wrote:
I want a div to have width:10em if the content
is narrow enough, but size it (not line-break),
when the content will become longer.


Use min-width for other browsers.

div {
min-width: 10em;
}

MSIE doesn't understand this. For MSIE, provoke QuirksMode, it will
extend the background to match overflowing content, I have heard it
said.

div { /* assumes QuirksMode */
overflow: visible;
width: 10em;
}

But that will set the max-width for other browsers, so either hide it
in conditional comments (recommended), or make the others work really
hard by adding:

div {
display: table-cell;
}

which MSIE doesn't understand but will cause the newer browsers to
ignore the width. If you want CSS1Compat mode, not QuirksMode, I got
no idea.

Disclaimer: it's after midnight.
--
Karl Smith.
Interim President,
International Global World "Jonathon Frakes
must never work in films again!" Society
Jul 20 '05 #2

P: n/a
Karl Smith wrote:
Disclaimer: it's after midnight.

Hey, that's when I do my best creative work. Whether it be web
document creation, 3D graphics., or whatever.

I'm an evening person.

--
Jim Jaworski,
Winnipeg, MB, Canada
http://www.mts.net/~jjaworsk/
Jul 20 '05 #3

P: n/a
Hi Karl!
I want a div to have width:10em if the content
is narrow enough, but size it (not line-break),
when the content will become longer.


Use min-width for other browsers.

div {
min-width: 10em;
}

MSIE doesn't understand this. For MSIE, provoke QuirksMode, it will
extend the background to match overflowing content, I have heard it
said.

div { /* assumes QuirksMode */
overflow: visible;
width: 10em;
}

But that will set the max-width for other browsers, so either hide it
in conditional comments (recommended), or make the others work really
hard by adding:

div {
display: table-cell;
}

which MSIE doesn't understand but will cause the newer browsers to
ignore the width. If you want CSS1Compat mode, not QuirksMode, I got
no idea.


Well, that's what I'm heading for. No QuirksMode, so it does not work.

But I thank you for your proposals!

Paul

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.