Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text running outside div 1

Status
Not open for further replies.

Blueman2

Technical User
Aug 5, 2008
27
US
I am testing out a layout and am having trouble containing text within a DIV. I thought i have done everything correctly but when I continue typing a line into #text-dash, it flows out horizontally into the container DIV.

I have looked closely at the HTML and CSS from a template supplied with dreamweaver where the text does not flow outside the DIV ("Sidebar") into the container and I can't really see any substantial differences in the code but I must be missing something. Can someone please take a look and give me a hand with this?

Thanks
Mike


I am including the code from my test page, followed by the code from the dreamweaver template



MY CODE:

<style type="text/css">
<!--
body {
margin: 0px;
padding: 0px;
}
#container {
background-color: #CC9966;
margin: 50px;
width: 600px;
float: left;
}
#test-dash {
background-image: url(img/nocities.jpg);
background-repeat: repeat-y;
width: 134px;
padding-top: 4px;
padding-right: 20px;
padding-bottom: 0px;
padding-left: 20px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
float: left;
}
-->
</style>
</head>

<body>
<div id="container">
<div id="test-dash">
<p>jkjkjjk jkjkjjj oiiiillplll;kjkjkjkjkjkjkjkkjkjkjkjkjk</p>
<p>iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</p>
<p>;;oioioioioioioioioioi;;;;jjj9iuiiii0-iiii0i0i0i0i0i0iiiiioioioioioioioioioioioioioioioi</p>
<p>iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii</p>
<p>&nbsp;</p>
<p>kjkkkkkkkkkkkkkkkkkkkkkkkk</p>
<p>&nbsp;</p>
<p>jkjkjjkjkjkjkjkkkkkkkkk,</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>vmmbvvvvbvbvvbvbvbvbvbvbvbvbv</p>
</div>
</div>
</body>
</html>



FROM THE TEMPLATE:

body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
color: #000000;
}
.twoColFixLt #container {
width: 780px; /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
background: #FFFFFF;
margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left; /* this overrides the text-align: center on the body element. */
}
.twoColFixLt #sidebar1 {
float: left; /* since this element is floated, a width must be given */
width: 200px; /* the actual width of this div, in standards-compliant browsers, or standards mode in Internet Explorer will include the padding and border in addition to the width */
background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */
padding: 15px 10px 15px 20px;
}
.fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 20px;
}
.fltlft { /* this class can be used to float an element left in your page */
float: left;
margin-right: 10px;
}
.clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
-->
</style>
<!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.twoColFixLt #sidebar1 { width: 230px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColFixLt #sidebar1 { padding-top: 30px; }
.twoColFixLt #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>

<body class="twoColFixLt">

<div id="container">
<div id="sidebar1">
<h3>Sidebar1 Content</h3>
<p>The background color on this div will only show for the length of the content. If you'd like a dividing line instead, place a border on the left side of the #mainContent div if it will always contain more content. </p>
<p>Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu, pellentesque eget, kkkjjjkcursus et, fermentum ut, s;;;;;;;;;;;;apien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh. Donec nec libero.</p>
<!-- end #sidebar1 --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<br class="clearfloat" />
<!-- end #container --></div>
</body>
</html>
 
Because your long texts are a single "word" without any brakes. No spaces. Browsers just won't arbitrarily cut a "word" and wrap it down to another line. Add spaces to it and you'll see it wrap.

You could also add Overflow:hidden; or overflow scroll to your div to contain the text or make it scroll if its longer than what the div can hold.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks Vacunita. I wasn't aware of that. It was very helpful. I'll use lorem ipsum from here in in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top