469,609 Members | 1,687 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Can you create a DIV that won't break from its content?

Is it possible to create a DIV that could be, for example, 300 x 200
pixels and make it so whatever content might appear in it, won't break it?

Let me try to explain:

Let's say I have a site with dynamic content, and I've created a DIV with
the above dimensions. Let's say the content was too big for the DIV. I
don't want the DIV to break and expand past its designated pixels. I'd
prefer for the content to be truncated somehow.

Is this possible?
--
[================================================== ===========================]
Sugapablo -> http://www.sugapablo.net
[================================================== ===========================]

Nov 23 '05 #1
3 2273
Els
Sugapablo wrote:
Is it possible to create a DIV that could be, for example, 300 x 200
pixels and make it so whatever content might appear in it, won't break it?

Let me try to explain:

Let's say I have a site with dynamic content, and I've created a DIV with
the above dimensions. Let's say the content was too big for the DIV. I
don't want the DIV to break and expand past its designated pixels. I'd
prefer for the content to be truncated somehow.

Is this possible?


Yes, just set overflow:hidden; or overflow:auto; for that div.
'hidden' will truncate it, 'auto' will make the contents scroll if
they need more space than the div is providing.

I've ignored your follow-up btw, as you didn't state it in the message
(not all newsreaders give a warning when a follow-up is set). This
means others would reply, without seeing the replies that are already
given.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Nov 23 '05 #2
Els wrote:
Sugapablo wrote:

Is it possible to create a DIV that could be, for example, 300 x 200
pixels and make it so whatever content might appear in it, won't break it? Is this possible?

Yes, just set overflow:hidden; or overflow:auto; for that div.
'hidden' will truncate it, 'auto' will make the contents scroll if
they need more space than the div is providing.


This does work perfectly well mechanically. Whenever I start thinking
about doing it, though, an internal alarm goes off. It tells me that
I'm trying to cram too much information onto a single page and that I'm
thinking too much like a print designer. There might still be a
special case where it is warranted, but I can't think of one off the top
of my head.
Nov 23 '05 #3
Sugapablo wrote:
Let's say I have a site with dynamic content, and I've created a DIV with
the above dimensions. Let's say the content was too big for the DIV. I
don't want the DIV to break and expand past its designated pixels.
Note that by setting the 'height' and 'width', the box should always be
that size and in standards compliant browsers, it will be. IE, however,
incorrectly treats 'height' and 'width' a little bit like 'min-height'
and 'min-width' (not exactly the same, though) and therefore breaks the
rules by increasing the size of the box to fit the content, which sounds
somewhat like the described behaviour that you don't want.
I'd prefer for the content to be truncated somehow.


overflow:hidden;

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Phil Powell | last post: by
1 post views Thread by 195.229.241.2 | last post: by
4 posts views Thread by Miguel Dias Moura | last post: by
1 post views Thread by dotNetDave | last post: by
18 posts views Thread by Steven Bethard | last post: by
15 posts views Thread by lxyone | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.