Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-28-2010, 02:53 AM   PM User | #1
johnmerlino
Regular Coder

 
Join Date: Oct 2009
Posts: 189
Thanks: 38
Thanked 3 Times in 3 Posts
johnmerlino is an unknown quantity at this point
unwanted horizontal scrolling occuring

Hey all,

I know that the overflow: autoo can cause horizontal scrolling when you specify a width and height. But in the below example, there's no need for it because the nested divs together only total 150px whereas the container is 180px, so why is horizontal scrolling occuring? Thanks for any response.
Code:
<body>
	<div style="width:180px; background-color: green; overflow: auto;">
		<div style="width: 100px; float: left;">
		Looking for <span style="font-style: italic">any </span> kind of appliance you may have to offer. 
		</div>
		<div style="width: 50px; float: right;">
		List of some of interested items
		<ul style="margin: 0; padding: 0;">
			<li style="margin: 0; padding: 0;">Refrigerator<li>
			<li style="margin: 0; padding: 0;">Oven<li>	
			<li style="margin: 0; padding: 0;">Microwave<li>	
			<li style="margin: 0; padding: 0;">Dishwasher<li>		
		</ul>	
		</div>
	<div>
</body>
johnmerlino is offline   Reply With Quote
Old 06-28-2010, 04:12 AM   PM User | #2
Candan
New Coder

 
Join Date: Jun 2010
Location: The Netherlands
Posts: 52
Thanks: 0
Thanked 6 Times in 6 Posts
Candan is an unknown quantity at this point
If you noticed how it still keeps the scrolling bar when you change the contains width to 200px, or even higher, you'll know its the float:right; doing it. I changed it to float:left; and it removed the scroll bar. If you want some space inbetween the 2 div's, add a margin-left:amount_of_pixels px; on the style.


Or instead of changing the float:right; to float:left; You could add a margin-right:25px; in the second div's style attribute.
Candan is offline   Reply With Quote
Reply

Bookmarks

Tags
css, div, html, overflow, scroll

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:44 PM.


Advertisement
Log in to turn off these ads.