div floats and width 100%

Reply

Join Date: Jul 2008
Posts: 95
Reputation: jakesee is an unknown quantity at this point 
Solved Threads: 4
jakesee jakesee is offline Offline
Junior Poster in Training

div floats and width 100%

 
0
  #1
Jul 8th, 2008
Hi people,

I'd very much appreciate some help with my issue here....

i have

  1. <div id='container'>
  2. <div id='left_pane_tab' style="float: left;" onclick='toggle(left_pane)'><img src="tab.gif" /></div>
  3. <div id='left_pane' style="float: left; display: none"><table style="width: 200px"> ... </table></div>
  4. <div id='content_area' style='width: 100%'></div>
  5. </div>

currently, the content_area extends beyond the browser's right bounds and a horizontal scroll bar is created by the browser to scroll.

how can I make the content_area stretches and occupy just up to the edge of the browser's viewable client area? (ie, the rest of the empty space to the right. of the left_pane.)


Thanks in advance!
Last edited by peter_budo; Jul 8th, 2008 at 1:03 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 302
Reputation: sreein1986 is an unknown quantity at this point 
Solved Threads: 33
sreein1986's Avatar
sreein1986 sreein1986 is offline Offline
Posting Whiz

Re: div floats and width 100%

 
0
  #2
Jul 9th, 2008
without style sheet how can i edit ...
Thanx,
Shiriyal

http://shiriyal.blogspot.com/
if you problem solved add me as a reputation and mark it mark as solved
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: div floats and width 100%

 
0
  #3
Jul 10th, 2008
First of all, if you want it to be 100 percent wide, don't float it. Instead, you need a style:

HTML and CSS Syntax (Toggle Plain Text)
  1. .wfl {width: 100%;}

To make an interior tag full width, all tags containing it must be 100% wide, all the way up to the body tag.

Otherwise, it takes 100% of the width of its container, but does not make the container any wider.
Last edited by MidiMagic; Jul 10th, 2008 at 11:25 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 95
Reputation: jakesee is an unknown quantity at this point 
Solved Threads: 4
jakesee jakesee is offline Offline
Junior Poster in Training

Re: div floats and width 100%

 
0
  #4
Jul 11th, 2008
To make an interior tag full width, all tags containing it must be 100% wide, all the way up to the body tag.
Still doesn't work.

With the following code, the behaviour in IE7 is what I want: The content area stretches to fill the remaining area on the right. The green background correctly fills that area.

In FF, which is not working, the content area takes the entire client area and the data_table extends beyond the right edge causing a horizontal scroll bar to appear at the bottom.

How do I write it such that it works in FF as well?

HTML and CSS Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title>Sample</title>
  4.  
  5. <style>
  6. body { margin: 0px; padding: 0px; width: 100%;}
  7. div { border: 1px solid #EEEEEE; }
  8. table { border: 5px solid #FF0000; }
  9.  
  10. #container {
  11. width: 100%;
  12. }
  13.  
  14. #left_pane_tab {
  15. float: left;
  16. }
  17.  
  18. #left_pane {
  19. float: left;
  20. display: block;
  21. width: 300px;
  22. border: 5px solid #0000FF;
  23. }
  24.  
  25. #content_area {
  26. background: #00FF00;
  27. width: 100%;
  28. height: 100%;
  29. }
  30.  
  31. .data_table {
  32. width: 100%;
  33. }
  34.  
  35.  
  36. </style>
  37.  
  38. <script>
  39. function toggle(id)
  40. {
  41. var pane = document.getElementById(id);
  42. if(pane.style.display == "block")
  43. pane.style.display = "none";
  44. else
  45. pane.style.display = "block";
  46. }
  47. </script>
  48.  
  49. </head>
  50.  
  51. <body>
  52. <div id='container'>
  53.  
  54. <div id='left_pane_tab'>
  55. <a href"#" onclick="toggle('left_pane'); return false;" />tab</a>
  56. </div>
  57.  
  58.  
  59.  
  60. <div id='left_pane'>
  61. <table>
  62. <tr><td>Apple</td></tr>
  63. <tr><td>Orange</td></tr>
  64. <tr><td>Pear</td></tr>
  65. <tr><td>Grape</td></tr>
  66. </table>
  67. </div>
  68.  
  69.  
  70. <div id='content_area'>
  71. <table class="data_table">
  72. <tr><td>Apple</td></tr>
  73. <tr><td>Orange</td></tr>
  74. <tr><td>Pear</td></tr>
  75. <tr><td>Grape</td></tr>
  76. <tr><td>Apple</td></tr>
  77. <tr><td>Orange</td></tr>
  78. <tr><td>Pear</td></tr>
  79. <tr><td>Grape</td></tr>
  80. <tr><td>Apple</td></tr>
  81. <tr><td>Orange</td></tr>
  82. <tr><td>Pear</td></tr>
  83. <tr><td>Grape</td></tr>
  84. </table>
  85. </div>
  86.  
  87.  
  88. </div>
  89.  
  90. </body>
  91. </html>
Last edited by jakesee; Jul 11th, 2008 at 5:07 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 315
Reputation: Thirusha is an unknown quantity at this point 
Solved Threads: 50
Thirusha's Avatar
Thirusha Thirusha is offline Offline
Posting Whiz

Re: div floats and width 100%

 
0
  #5
Jul 11th, 2008
can u provide the screen shot of how it is looking in ie7, i just cant understand what u want it to look like, i think the cold here in SA has frozen my brain.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 95
Reputation: jakesee is an unknown quantity at this point 
Solved Threads: 4
jakesee jakesee is offline Offline
Junior Poster in Training

Re: div floats and width 100%

 
0
  #6
Jul 11th, 2008
Originally Posted by Thirusha View Post
can u provide the screen shot of how it is looking in ie7, i just cant understand what u want it to look like, i think the cold here in SA has frozen my brain.
Click image for larger version

Name:	left pane collapse.jpg
Views:	7
Size:	9.2 KB
ID:	6582

Click image for larger version

Name:	left pane expand.jpg
Views:	8
Size:	10.9 KB
ID:	6583
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 95
Reputation: jakesee is an unknown quantity at this point 
Solved Threads: 4
jakesee jakesee is offline Offline
Junior Poster in Training

Re: div floats and width 100%

 
0
  #7
Jul 11th, 2008
In case you also need FF screenshots, here it is:

Click image for larger version

Name:	ffnoscroll.jpg
Views:	5
Size:	10.8 KB
ID:	6584

Click image for larger version

Name:	ffscroll.jpg
Views:	4
Size:	11.8 KB
ID:	6585
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: div floats and width 100%

 
0
  #8
Jul 12th, 2008
It looks like your script is turning some styles on and off. The others might or might not be switched on and off.

Also, you have surrounding styles (margin, border, padding) and size styles (height, width) assigned to the same tag. This causes incompatibilities between IE and FF.

Height of 100% can cause unpredictable results. It isn't really defined for anything except an object inside another container with a defined height.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 95
Reputation: jakesee is an unknown quantity at this point 
Solved Threads: 4
jakesee jakesee is offline Offline
Junior Poster in Training

Re: div floats and width 100%

 
0
  #9
Jul 12th, 2008
Originally Posted by MidiMagic View Post
Height of 100% can cause unpredictable results. It isn't really defined for anything except an object inside another container with a defined height.
ok.. then how shoud it be done properly ?
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 164
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: div floats and width 100%

 
0
  #10
Jul 14th, 2008
What are you TRYING to do. It is not clear.

Height is not normally intended to be defined. The entire idea of a web page is to fit the width of the current browser window, and then expand downward as needed until all of the content can be rendered.

The one thing you can NOT do is make a page that exactly fills the browser window. Too many people are pulling their hair out trying to do this. But as long as computers and monitors exist with different screen resolutions, and as long as people can resize their browser windows, and add toolbars to browsers, you are not going to exactly fit your page on one screen.

So you compromise. You let your text expand downward, to flow around your other objects. You use percentage widths or floats to place things. You leave enough whitespace between objects, so the extra space can shrink if a smaller browser window is used. And you don't get mad if your page needs to be scrolled to be read.
Last edited by MidiMagic; Jul 14th, 2008 at 5:54 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC