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

Layout question: padding 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.

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
3 2268
Scripsit Kaz Kylheku:
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>
Does your actual test document contain the syntax error, too? Please post a
URL to avoid embarrassing typos that don't relate to the problem at hand.
In the style sheet, I lay these out horizontally blocks within a line
box, say like this:

.box { display: inline; width: 10em; }
This is strange in two accounts:
1) You have decided to use <divinstead of <span>, and yet you declare
display: inline. What's the point? Apart from content models, the only
difference between <divand <spanis that by default the former is
displayed as a block and the latter is displayed as inline.
2) You're setting the width, even though the property does not - by CSS
specs - apply to inline elements, and it's the display property that counts
here.
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.
The simplest way is probably to remove the display setting and use

box { float: left; }
#three { float: right; }
..clear { clear: both; }

where "clear" is a class assigned to the element immediately following the
elements under discussion.

However, if the available width does not allow the boxes to be displayed at
the same line, they'll be split across two or three lines. In normal
circumstances, this is _good_ - but you haven't revealed the context at all,
so I can't tell about your actual situation.

P.S. Your question was more of a CSS question than an HTML question, right?
So it would belong to c.i.w.a.stylesheets.

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

Jan 11 '07 #2
Scripsit Jukka K. Korpela:
P.S. Your question was more of a CSS question than an HTML question,
right? So it would belong to c.i.w.a.stylesheets.
Aaaargh, Kaz Kylheku _multiposted_ the question. Don't do multipost, mm'kay?

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

Jan 11 '07 #3
Jukka K. Korpela wrote:
Scripsit Jukka K. Korpela:
P.S. Your question was more of a CSS question than an HTML question,
right? So it would belong to c.i.w.a.stylesheets.

Aaaargh, Kaz Kylheku _multiposted_ the question. Don't do multipost, mm'kay?
Nope. Canceled the original and reposted in the appropriate newsgroup.
I don't have access to a real news server, only Google Groups.
Otherwise I would have tried superseding the article with a different
newsgroups header.

Jan 12 '07 #4

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

Similar topics

0
by: Ethan | last post by:
I'm trying to set up a page with a header and 2 columns. I would like to use <div>s rather than tables. The page is here... http://64.142.13.246/style_testing_site/style_model2.htm In both IE...
1
by: Ethan | last post by:
I've been trying to get a layout to work right, but so far haven't been able to do so. Here's the layout: http://64.142.13.246/style_testing_site/style_model3.htm This is the basic idea: ...
2
by: Ethan | last post by:
I'm trying to set up a page with a header and 2 columns. I would like to use <div>s rather than tables. The page is here... http://64.142.13.246/style_testing_site/style_model2.htm In both IE...
7
by: Drew Martin | last post by:
The page at the below URL renders perfectly in IE6, but is failing horribly in Firefox (0.7, 0.8). I can't figure out why and was hoping someone could take a quick look at it. Most of the layout...
30
by: Diane Wilson | last post by:
I'm trying (once again) to figure out how to make a robust CSS layout style that can replace tables. I'd like to be able to do a basic two-column layout, with a one-column header, a two column...
10
by: Volker Lenhardt | last post by:
For a QApplication (PyQt) on the small screen of my Zaurus 5500 PDA I try to layout my data output in a QScrollView as the central widget. I'd prefer to use QGridLayout, but cannot add it to the...
28
by: kyle york | last post by:
Greetings, Why does the C standard require the members of a structure not be re-ordered (6.2.5.20)? Padding is allowed, and platform dependent, which means one cannot rely on the exact layout...
1
by: jimchapuk | last post by:
I created a two column CSS layout by floating the columns left and right respectively. When I put text into the first column (via HTML) it continues in a straight line through the second column...
5
by: creative1 | last post by:
hi everyone, I am struck in layout of my site. Im using 1024 fixed width layout. I have a site layout designed in psd files. Bisically I have to stick with that design tightly and I am asked not to...
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: 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
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
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...

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.