Forum Moderators: not2easy

Message Too Old, No Replies

Align Text Right of DIV

         

learn4life

10:23 pm on Apr 23, 2008 (gmt 0)

10+ Year Member



I have 2 divs, one with an image, the other with the image's caption. The divs are layed out vertically.

The div does not take up the entire width of the page, the problem I'm having is that I have content that I would like to wrap to the right of the divs but cannot get it to do so.

Would appreciate if someone can look at my code and tell me what the issue is. Thanks.

CODE:
div.about {
width: 200px;
float: left;
margin: 0px 1px 5px 0px;
background-color: #000000;
border: 0px #a45c0b solid;
padding: 0px 2px 5px 1px;
}

div.abouttitle {
width: 200px;
float: left;
color: #ffffff;
text-align: center;
font-size: 11px;
font-weight: bold;
margin: 0px 1px 5px 0px;
background-color: #004c78;
border: 1px #bd0f13 solid;
padding: 0px 2px 5px 1px;
}

learn4life

10:25 pm on Apr 23, 2008 (gmt 0)

10+ Year Member



I forgot to add that the code works in firefox, internet explorer is what is causing the problem.

Thanks again.

D_Blackwell

10:42 pm on Apr 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure that there is enough code for me to fully understand the question. Perhaps you can emend the sample HTML to replicate the issue and question.

<html>
<head>
<style>
div.about {
width: 200px;
float: left;
margin: 0px 1px 5px 0px;
background-color: red;
/*#####0px means no border##### border: 0px #a45c0b solid;*/
padding: 0px 2px 5px 1px;
}
div.abouttitle {
width: 200px;
float: left;
color: #fff;
text-align: center;
font-size: 11px;
font-weight: bold;
margin: 0px 1px 5px 0px;
background-color: #004c78;
border: 1px #bd0f13 solid;
padding: 0px 2px 5px 1px;
}
</style>
</head>
<body>
<div class="about">
DIV - about
<div class="abouttitle">
DIV - abouttitle
</div>
</div>
<div>
Content to the right of the floated divs.
</div>
<!--
I have 2 divs, one with an image, the other with the image's caption. The divs are layed out vertically.

The div does not take up the entire width of the page, the problem I'm having is that I have content that I would like to wrap

to the right of the divs but cannot get it to do so.
-->
</body>
</html>

swa66

12:34 am on Apr 24, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's a common side effect of IE's broken box model than content doesn't fit anymore in the parent's width.

width in IE includes the padding, not just the content's width.

Easiest to solve it is to recalculate all those widths that get affected and put that in a conditional comment.