473,382 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 6868
On Tue, 3 Aug 2004 10:22:33 -0500, kaeli <ti******@NOSPAM.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******@NOSPAM.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:table" to your #body rules.

--
Spartanicus
Jul 20 '05 #3
In article
<7f********************************@news.spartanic us.utvinternet.ie>,
me@privacy.net enlightened us with...
kaeli <ti******@NOSPAM.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:table" 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 indistinguishable
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******@NOSPAM.comcast.net>
wrote:
In article
<7f********************************@news.spartani cus.utvinternet.ie>,
me@privacy.net enlightened us with...
kaeli <ti******@NOSPAM.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:table" 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.invalid> wrote:
kaeli <ti******@NOSPAM.comcast.net> wrote:
me@privacy.net enlightened us with...
kaeli <ti******@NOSPAM.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:table" 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.invalid> 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:table" 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
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...
15
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...
16
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...
0
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...
3
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...
19
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...
21
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...
7
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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.