views:

41

answers:

3

Hi!

I could swear I've seen articles about this problem, but I can't for the life of me find them again! Basically if I have

<div style="width: 250px;">The width of this div should be no less than 250px wide</div>

In the code below, the content in the div isn't restricting it's width to the width specified causing an overflow problem:

        <div class="PostIt">
            <div id="tags"><span class="qExtraLarge"><a href="Team/Default.aspx#lucky">Lucky Khumalo</a></span>
            <span class="qLarge"><a href="Investments/Social/School/Default.aspx">School</a></span>
            a;orghaepoht8aegae[hgi'aehg[ahgiha[e8gjaerghuoaeir'ghu;dsOsgh;vrwi/jbvh?URbnIRWhb'a[985h[qygherionhbdl</div>

        </div>

.PostIt { display: block; text-align: left; padding: 30px 30px 30px 30px; height: 240px !important; width: 190px !important; background: transparent url("Images/PostIt.png"); }
.PostIf #tags { width: 250px !important; }

Any suggestions would be great!

Thanks in advance.

A: 

Hide your overflow.

Or more precisely

.myclass { overflow: hidden; }
NickLarsen
+1  A: 

Setting a width on a block element alone won't stop any contents that are wider than that width from overflowing the bounds of the element. To do that you need to also set the "overflow" property. Setting it to "hidden" will simply hide anything outside the bounds, but you can also set it to other values to automatically show scrollbars, etc.

See http://reference.sitepoint.com/css/overflow for a good explanation of the overflow CSS property.

Damian Edwards
neither hiding overflow or scrollbars is good enough, I need to basically set word wrap for the content
Logan Young
yeah, unbroken long "words" will always play havoc with your layout. The word-wrap property is in CSS 3 but is pretty well supported already (was actually invented by MS a while back).
Damian Edwards
+2  A: 

If you want to hide any overflowing content, use overflow:hidden;

If you want to show the content and just force a line break, use word-wrap:break-word;

washwithcare
It seems `word-wrap: break-word;` didn't help. I saw no difference at all (Using Google Chrome), but I did notice a change when I set margins to the block...
Logan Young