473,804 Members | 3,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

divs vs tables; overflow without scrollbars


I've been trying to get away from using tables as a layout tool, but I've
just come across what I consider to be a serious liability.
If I specify a width (minimum, really) in a div, such as

#body {
width: 90%;
margin-left: 5%;
margin-right: 5%;
border: 1px solid navy;
padding: 10px;
}

And then I put a table in that div, when the table data gets too large, it
runs outside the box instead of the box expanding. I understand that this is
expected behavior (though IE will indeed expand the box, other browsers
implement the "correct" behavior and either cut off the content or expand it
beyond the box depending on my overflow setting). If I set the overflow to
auto, I get ugly scroll bars. I don't like it.
If I use a table instead, and put a table inside, the containing table
expands.

Is there a way to get that behavior with divs or am I out of luck on this
one?
To clarify, I want a box with a border that usually takes up 90% of the
window, but expands if the content inside is too big to fit. I could use a
table, but would like to use a div/CSS if I can.

TIA

--
--
~kaeli~
Do not taunt Happy Fun Ball!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #1
7 6885
On Tue, 3 Aug 2004 10:22:33 -0500, kaeli <ti******@NOSPA M.comcast.net>
wrote:

I've been trying to get away from using tables as a layout tool, but I've
just come across what I consider to be a serious liability.
If I specify a width (minimum, really) in a div, such as

#body {
width: 90%;
margin-left: 5%;
margin-right: 5%;
border: 1px solid navy;
padding: 10px;
}


If you mean "minimum width" then you really want the min-width
property, but sadly that's not supported in Internet Explorer.

My usual strategy is to either just ignore IE completely and let it
get it "almost right" (normally the content will shove the box out
anyway) or to play some tricks on IE's flakey CSS parser so that it
sees different rules to everything else.

In think in your case the first is the better plan, because at least
then your DIV box will expand to contain whatever you put inside it,
even if it does end up a little wider than what you really wanted.

Up to you, though! :)

All the best,
-Claire
Jul 20 '05 #2
kaeli <ti******@NOSPA M.comcast.net> wrote:
To clarify, I want a box with a border that usually takes up 90% of the
window, but expands if the content inside is too big to fit. I could use a
table, but would like to use a div/CSS if I can.


Add "display:ta ble" to your #body rules.

--
Spartanicus
Jul 20 '05 #3
In article
<7f************ *************** *****@news.spar tanicus.utvinte rnet.ie>,
me@privacy.net enlightened us with...
kaeli <ti******@NOSPA M.comcast.net> wrote:
To clarify, I want a box with a border that usually takes up 90% of the
window, but expands if the content inside is too big to fit. I could use a
table, but would like to use a div/CSS if I can.


Add "display:ta ble" to your #body rules.


Sweet!!
Excellent.
Worked like a charm, at least in IE6 and NN7. I didn't test other browsers,
as this is an intranet app.

Thanks a lot!

--
--
~kaeli~
Any sufficiently advanced technology is indistinguishab le
from magic.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4
On Tue, 3 Aug 2004 12:56:04 -0500, kaeli <ti******@NOSPA M.comcast.net>
wrote:
In article
<7f*********** *************** ******@news.spa rtanicus.utvint ernet.ie>,
me@privacy.n et enlightened us with...
kaeli <ti******@NOSPA M.comcast.net> wrote:
>To clarify, I want a box with a border that usually takes up 90% of the
>window, but expands if the content inside is too big to fit. I could use a
>table, but would like to use a div/CSS if I can.


Add "display:ta ble" to your #body rules.


Sweet!!
Excellent.
Worked like a charm, at least in IE6 and NN7. I didn't test other browsers,
as this is an intranet app.


It worked in IE6?! I've never seen CSS tables work in IE6 before.

I'd verify this for myself, but unfortunately (or perhaps
fortunately!) I'm not using Windows at the moment.

All the best,
-Claire
Jul 20 '05 #5
Claire Tucker <fa**@invalid.i nvalid> wrote:
kaeli <ti******@NOSPA M.comcast.net> wrote:
me@privacy.ne t enlightened us with...
kaeli <ti******@NOSPA M.comcast.net> wrote:

>To clarify, I want a box with a border that usually takes up 90% of the
>window, but expands if the content inside is too big to fit. I could use a
>table, but would like to use a div/CSS if I can.

Add "display:ta ble" to your #body rules.

Worked like a charm, at least in IE6 and NN7. I didn't test other browsers,
as this is an intranet app.

It worked in IE6?! I've never seen CSS tables work in IE6 before.


display: table; is ignored in IE6, but IE6 was already 'working'
because it incorrectly treated the width as a min-width. Hence, only
those browsers that support display: table; actually 'needed' it in
this case.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net > <http://steve.pugh.net/>
Jul 20 '05 #6
Claire Tucker <fa**@invalid.i nvalid> wrote:
>To clarify, I want a box with a border that usually takes up 90% of the
>window, but expands if the content inside is too big to fit. I could use a
>table, but would like to use a div/CSS if I can.

Add "display:ta ble" to your #body rules.


Sweet!!
Excellent.
Worked like a charm, at least in IE6 and NN7. I didn't test other browsers,
as this is an intranet app.


It worked in IE6?! I've never seen CSS tables work in IE6 before.


No it doesn't work in IE, but the OP was having trouble with "other
browsers", IE already did it's famous "what the author wanted" thing,
and since IE ignores the display:table rule the poor ole thang wasn't
harmed.

--
Spartanicus
Jul 20 '05 #7
In article <11************ *************** *****@4ax.com>, st***@pugh.net
enlightened us with...

display: table; is ignored in IE6, but IE6 was already 'working'
because it incorrectly treated the width as a min-width. Hence, only
those browsers that support display: table; actually 'needed' it in
this case.


I figured that was the case. Thanks for the clarification.

--
--
~kaeli~
The man who fell into an upholstery machine is fully
recovered.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
14585
by: Kai Grossjohann | last post by:
I'm trying to synchronize the scrolling of two <div> elements. The top element is for showing column headers, the bottom div shows the table rows. I consed up the following HTML/JavaScript concoction which does something useful in IE and also in Mozilla 1.4. However, the problem is that it only works in Mozilla if I say overflow:auto in the top frame, it ceases working if I say overflow:hidden. But saying overflow:hidden is...
15
4838
by: Andrew Fedoniouk | last post by:
I have a simple test document which produce the following in Mozilla and Opera: http://terrainformatica.com/w3/p2/problem1.png Internet Explorer behaves as per recommendation (I guess) Did I miss something and width of paragraph can be set less than its content (without overflow specification)? Document is here: http://terrainformatica.com/w3/p2/problem1.htm
16
2311
by: Pierre Jelenc | last post by:
I need to lay out a page with five main elements: A fixed div at the top containing a navigation bar, two side-by-side columns, a centered shopping cart at the bottom, and a full-window fixed div to provide a border. A test page is at http://www.marcvonem.com/discography.html The navigation bar and absolutely positioned side by side columns look fine (with a few cosmetic problems that will be dealt with later) but I cannot figure out...
0
1493
by: Paul E Collins | last post by:
Hello. Suppose I use the following code to split a Web page into four separately scrollable quarters, each having 50% page width and 50% page height. Is it then possible to add *fixed*-height header and footer divs without possibly tipping the total page height over 100%? How would this be coded? (I ask mainly out of academic interest. No doubt this layout has usability issues.)
3
19081
by: Otto de Voogd | last post by:
I posted the problem below in alt.www.webmaster before, but no-one knew the answer, however someone suggested this group as a good place to ask. I am trying to fit images into a browser window using CSS and in particular overflow:auto; The idea being that if a user's window is too small the image becomes scrollable (horizontally) and a horizontal scrollbar appears. It works nicely in Firefox and Opera but with Internet Explorer 7 a...
19
6206
roula
by: roula | last post by:
I HATE DIVS AND DIFFERENT BROWSERS!!! i spent the whole day and night searching for a way to center align stupid divs, the problem is that the code is so sensitive, i lost my mind trying to make them work in a certain way (like some should scroll with a fixed background and others shouldn't scroll bla bla..) and the divs are nested and positioned in different ways and if i change something it gets messed up and what works in in IE doesn't work...
21
2403
by: daydream | last post by:
yeah i need some help(such a common line) ,i have a menu and each link has its own div respectively and yeah obviously when u click the link the div shows, the problem is i would like each div to show no matter how many times you click the link for it and if you click on another one and when u go back to the original , the div would still show. at the moment i have partially done that, i click on item a ,that shows then when i click item b that...
7
7833
by: rcw1983 | last post by:
I'm trying to get two divs on the same line....the problem I have is when the browser window gets smaller, the second div is being pushed below the first div....I want them to stay on the same line. Here is my code: <div style="white-space:nowrap"> <div style="float:left"> Left Column </div> <div style="float:left;margin-left:10px">
4
2041
by: Steffan A. Cline | last post by:
I have a situation where I am making a calendaring solution and need to have 5 scrollable divs side by side in a week view but the week div needs to scroll left and right. As it sits now, unless the week div is set to something like 1500px, they wrap. The idea is not to have the browser scroll left and right. Unfortunately this needs to work in IE6 also. =( <div style="overflow:scroll; height: 500px; width: 700px;"> <div...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.