473,387 Members | 1,760 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,387 software developers and data experts.

Slack space within line box.

I have a structure of three boxes contained within a box, like this:

<div class="line">
<div class="box" id="one">one</div>
<div class="box" id="two">two</div>
<div class=box" id="three">three</div>
</div>

In the style sheet, I lay these out horizontally blocks within a line
box, say like this:

..box { display: inline; width: 10em; }

These three boxes do not fill the entire width of the containing box,
leaving a space on the right. What I would like to do is to place
..box#three all the way to the right of the containing box, and leave
the other two to the left. You know, something like using infinitely
stretchable glue in a TeX \hbox.

Instead of this:

[[ one ][ two ][ three ] .......... ]

I want this:

[[ one ][ two ] .......... [ three ]]

Using absolute positioning for .box#three is not an option, because
then its height is ignored. I still want the height of the overall box
to be calculated on all three of these elements. Sometimes box three
has extra material in it: text which wraps to several lines. If that is
ignored in the line height calculation, the box then overlaps the next
linebox below.

Floating doesn't seem to do the job. Although [ three ] will move to
the right, it is not positioned as high as possible, so it looks like
this:

[[ one ][ two ] .................
.........................[ three ]]

Ideally, I want to be able to set the width of the line box arbitrarily
without having to adjust any other number. So for instance I don't want
to stick in an invisible box of a fixed width such that the boxes
happen to add up to the total width of the containing box. Relative
positioning, simply shifting [ three ] over, won't cut it either.

In Explorer I can't even see to be able to control the width of that
box. If I set the width of <body>, or other elements, they are just
ignored: the width dynamically follows the resizing of the browser
window. On that browser, I'd like [ three ] to have right "bit
gravity": stick with the right edge of the window. Elements which are
absolutely positioned with right: 0 do behave that way.

Is there a way to attribute stretchable box such that it automatically
fills slack within a line box?

Jan 11 '07 #1
10 2314
Scripsit Kaz Kylheku:
I have a structure of three boxes contained within a box, like this:
And you multiposted your question (at least here and c.i.w.a.html). That's
_bad_. Naughty. Disruptive.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 11 '07 #2
Jukka K. Korpela wrote:
Scripsit Kaz Kylheku:
I have a structure of three boxes contained within a box, like this:

And you multiposted your question (at least here and c.i.w.a.html). That's
_bad_. Naughty. Disruptive.
I canceled the posting in c.i.w.a.html, because I realized that it was
off topic there, because it's a style sheet question, not a HTML
question. Then I immediately reposted it here.

The new post may have reached your server before the cancelation of the
old post.

Thanks for your highly topical and informative reply though; my
program's layout looks better already.

Jan 12 '07 #3
Jukka K. Korpela wrote:
Scripsit Kaz Kylheku:
I have a structure of three boxes contained within a box, like this:

And you multiposted your question (at least here and c.i.w.a.html). That's
_bad_. Naughty. Disruptive.
I realized that the article didn't belong in a HTML newsgroup, so I
canceled it. Then I reposted it here. Cancelations and postings can
race ahead of each other, and perhaps not reach the same set of
servers. Ah well. I see your reply in the other newsgroup.

Jan 12 '07 #4
Hi, Kaz

I had similar question in the past "Fixed and variable width boxes on
one line",
http://groups.google.com/groups/sear...ne&qt_s=Search

Here is a slightly modified version:

= = = = = = =
<html>
<head>
<style type="text/css">
<style type="text/css">
<!--
#one {
background:silver;
width: 100px;
float: left;
border:1px maroon solid;
}
#two {
background:silver;
width: 100px;
float: right;
border:1px maroon solid;
}

#three {
background:orange;
margin-left:100px;
margin-right:100px;
position: relative;
width: auto;
border:1px maroon solid;

/* Adding this tag produce unexpected spaces in IE6*/
height: 70px;
}

-->
</style>
</head>

<body>
<div>
<div id="container">
<div id="one">one</div>
<div id="two">two</div>
<div id="three">three</div>
</div>
</div>

</body>

</html>
= = = = = = =

- Alex

Jan 12 '07 #5
Alex wrote:
Here is a slightly modified version:
Did you modify it to add the errors?
= = = = = = =
<html>
<head>
<style type="text/css" <--- error, not needed
<style type="text/css">
<!-- <-- remove HTML comment marks
#one {
<snip>
}

-- <-- remove HTML comment marks
</style>
....

--
-bts
-Motorcycles defy gravity; cars just suck
Jan 12 '07 #6
Alex wrote:
Hi, Kaz
Here is a slightly modified version:
#two {
background:silver;
width: 100px;
float: right;
border:1px maroon solid;
}

#three {
background:orange;
margin-left:100px;
margin-right:100px;
position: relative;
width: auto;
border:1px maroon solid;

/* Adding this tag produce unexpected spaces in IE6*/
height: 70px;
}
Beyond the errors already noted by BTS, we should note that the order of
your divs is different from the OP's desires. The OP said:
I want this:

[[ one ][ two ] .......... [ three ]]

Your code provides:

[[ one ][ threeeeeeeeeeeeeeee ][ two ]]

--
John
Jan 12 '07 #7
Alex wrote:
Hi, Kaz

I had similar question in the past "Fixed and variable width boxes on
one line",
http://groups.google.com/groups/sear...ne&qt_s=Search
You have to float "one", left - "three", right - and allow "two" to flow
between the others .... with css.
In the html you have to present them in this order: "one", "three" and
then "two".
Like so:

<style>
#one {float:left;}
#two {}
#three {float:right;}
..clear {clear: both;}
</style>

<div class="line">
<div class="box" id="one">one</div>
<div class="box" id="three">three<br>3.1<br>3.2</div>
<div class="box" id="two">two</div>
<br class="clear">
</div>

--
Gus
Jan 12 '07 #8
Alex wrote:
Hi, Kaz

I had similar question in the past "Fixed and variable width boxes on
one line",
http://groups.google.com/groups/sear...ne&qt_s=Search

Here is a slightly modified version:
None of the suggestions involving floats work properly with both IE6
and Firefox 1.0.4.

So after hours of late-night experimentation, I gave up and used
absolute positioning.

Under Firefox, the floats apparently do not participate in the height
calculation; they are treated as being outside of the normal flow. So
what happens is that the entire UI turns into a vertically-scrunched
dog's breakfast.

When you add set the height property of your line box class to be at
least as large as the tallest item in the line, then, and only then,
the display looks fine. But, if you are going to be computing the line
height yourself, you might as well then use absolute positioning.

Maybe this is fixed in some newer version of Firefox, but do you really
want to write apps that require the user to install last night's build
of the browser? :)

A part of my UI displays a Chinese character as the leftmost element in
the line box. The user can specify the size of these characters in a
selection list box in another place in the UI. So the row has to be at
least as tall as these characters for proper spacing and of course at
least as tall as the other elements.

Since I'm generating dynamic HTML, what I do is generate an in-line
style block which sets the size of these characters with the dynamic
value. And in that same block, the program calculates and spits out a
ruleset to set the line height for the rows in that section of the
document where those characters appear.

It's an ugly hack, but not a big one.

Jan 12 '07 #9
On 2007-01-12, Kaz Kylheku <kk******@gmail.comwrote:
[snip]
None of the suggestions involving floats work properly with both IE6
and Firefox 1.0.4.

So after hours of late-night experimentation, I gave up and used
absolute positioning.

Under Firefox, the floats apparently do not participate in the height
calculation; they are treated as being outside of the normal flow.
They participate in the height calculation of the "block formatting
context root" but not of the containing box. It's all as specified, and
you could very likely have got the effect you wanted by using "clear",
which IIRC is exactly what Jukka suggested when he first mentioned
floats, or alternatively by floating the container as well.
Maybe this is fixed in some newer version of Firefox, but do you really
want to write apps that require the user to install last night's build
of the browser? :)
It's not a bug. This came up quite recently and I tried to explain it
http://tinyurl.com/yjzsc6, if you're interested.
Jan 12 '07 #10
Ben C wrote:
On 2007-01-12, Kaz Kylheku <kk******@gmail.comwrote:
Under Firefox, the floats apparently do not participate in the height
calculation; they are treated as being outside of the normal flow.

They participate in the height calculation of the "block formatting
context root" but not of the containing box. It's all as specified, and
you could very likely have got the effect you wanted by using "clear",
which IIRC is exactly what Jukka suggested when he first mentioned
floats, or alternatively by floating the container as well.
Indeed, that is exactly what I did. I added extra dummy elements in the
HTML, and style-ized them with the recommended clear. It worked on IE6.
Almost.
Maybe this is fixed in some newer version of Firefox, but do you really
want to write apps that require the user to install last night's build
of the browser? :)

It's not a bug. This came up quite recently and I tried to explain it
http://tinyurl.com/yjzsc6, if you're interested.
Aha, in this thread there is a posting by Bergamont (Usenet message ID
<4v*************@mid.individual.net>) which points to this:
http://www.quirksmode.org/css/clearing.html

This page documents exactly the be behavior I saw at first when I
implemented the dummy clear element: the artifact of the element
causing an extra horizontal box underneath the floats, causing lots of
vertical space being added to the document. Not knowing about the
"overflow: auto;" workaround, I hacked it differently. Setting the
height of the containing box to 0 seemed to do the trick. No luck on
Firefox. Maybe this overflow:auto ; trick will work, though. I will
give the float solution another try.

Jan 13 '07 #11

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

Similar topics

21
by: Christian Seberino | last post by:
Linux kernel style guide, Guido's C style guide and (I believe) old K&R style recommends 8 SPACES for indent. I finally got convinced of wisdom of 8 space indentation. Guido also likes 8 space...
6
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
1
by: Mark247 | last post by:
Hi, When transforming an XSLT to HTML I get a very annnoying white spac gap of about 2px under each image. This is particularly annoying as am creating a vertical navigation menu made up of images...
11
by: Victor Martin | last post by:
Bold text in proportional fonts use up more space than non-bold text. Is there a way to keep the space bold takes up within the limits of the regular text while keeping the same font?
13
by: DM | last post by:
If I put three images next to each other (each within an anchor tag) they all line up horizontally as expected with no space between them. I.e., they're sitting flush up against each other. ...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
5
by: Yasaswi Pulavarti | last post by:
does a command like, db2 drop table tabschema.tabname when run from the Aix prompt reclaim the disk space? Are there any other options? How can we make sure the disk space is reclaimed? Thanks,...
4
by: Keith Hughitt | last post by:
For example, If you have a list: <ul> <li>item 1 is short.</li> <li>item 2 is a little bit longer</li> </ul> regardless of the size of the contents of each list item, the element
7
by: ganesh gajre | last post by:
Hi all, I want to read file which is mapping file. Used in to map character from ttf to unicode. eg Map file contain data in the following way: 0 ० 1 १
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...

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.