473,594 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

floating div with width:auto looks "wrong" in gecko browsers

day
I know I've seen this issue described before, but I can't find it, or
the solution now that I need it.

I have some css-specified floating divs that contain images or text.
The text divs have a background color and text color that differ from
the rest of the page, and I'd like them to be positioned from the
right edge of the rightmost image div, to the right edge of the
browser window. In other words, if the browser window is 800 pixels
wide, and there is image content occupying the leftmost 650 pixels of
the screen, I want my text div to occupy the rightmost 150 pixels; if
the images are 500 pixels wide, the text div will be 300 pixels wide,
and so on.

(The above is a bit of an oversimplificat ion overlooking margins,
padding, div borders, etc., but it's the "big picture" I'm after).

By setting text div width: auto in my css, I get what I want in IE:
the text div is as wide or narrow as needed to go from some point in
the middle of the browser window to the right edge.

Not so though with gecko browsers. In current versions of both
Firefox and Netscape, the text div is forced down below the image
divs, so it starts at the left edge of the browser window and is 100%
of the browser window width.

So...

WHAT I WANT: Text div occupies 100% of the REMAINING width of the
browser window, filling in the part not occupied by other divs that
occupy anywhere from the leftmost 100 pixels to the leftmost 750
pixels of the browser window.

WHAT I'M GETTING: Gecko browsers force the text div to start on the
left edge of the browser window so it occupies 100% of the TOTAL (vs.
remaining/available) browser window width.

I realize that the Gecko browsers are adhering to the standard and IE
is not. But whatever the reason, I want to know how to get stuff to
render as I'd like it to, as described above.
Jul 21 '05 #1
18 5707
day <Da*@theraces.i nvaliddomain> wrote:

[snip]
(The above is a bit of an oversimplificat ion overlooking margins,
padding, div borders, etc., but it's the "big picture" I'm after).


As per usual an uploaded example is worth a thousand words, your
description contains contradictions and lacks essential information.

Is this what you are after?:
http://homepage.ntlworld.com/spartanicus/day.htm

or do you want a "column" layout?

--
Spartanicus
Jul 21 '05 #2
day
On Mon, 23 May 2005 07:47:43 GMT, Spartanicus
<in*****@invali d.invalid> wrote:
day <Da*@theraces.i nvaliddomain> wrote:

[snip]
(The above is a bit of an oversimplificat ion overlooking margins,
padding, div borders, etc., but it's the "big picture" I'm after).


As per usual an uploaded example is worth a thousand words, your
description contains contradictions and lacks essential information.

Is this what you are after?:
http://homepage.ntlworld.com/spartanicus/day.htm

or do you want a "column" layout?


Thanks, good point. The following html is a stripped-down segment
from something I'm doing, that illustrates the issue perfectly.

<html>
<head>
<style type="text/css">
<!--
body { background-color: #333 }
..imgdiv { float: left; margin: 4px }
..textdiv { background-color: #009; margin: 8px; padding: 5px; float:
left; width: auto; color: fff; }
-->
</style>
</head>
<body>
<div class="imgdiv">
<img src="foo.jpg" height="283" width="360" />
</div>
<div class="textdiv" >
<p>I would like this area to line up with the top of this div even
with the top of the foo.jpg image, and extending from just to the
right of the foo.jpg image, all the way to the right edge of the
browser. It shows up as I want in IE 6.0, but in Netscape 7.x or FF
1.x it shows up UNDER the image, extending across the width of the
browser window.</p>
</div>
</body>
</html>

Jul 21 '05 #3
Els
day wrote:
On Mon, 23 May 2005 07:47:43 GMT, Spartanicus
<in*****@invali d.invalid> wrote:
day <Da*@theraces.i nvaliddomain> wrote:

[snip]
(The above is a bit of an oversimplificat ion overlooking margins,
padding, div borders, etc., but it's the "big picture" I'm after).


As per usual an uploaded example is worth a thousand words, your
description contains contradictions and lacks essential information.

Is this what you are after?:
http://homepage.ntlworld.com/spartanicus/day.htm

or do you want a "column" layout?


Thanks, good point. The following html is a stripped-down segment
from something I'm doing, that illustrates the issue perfectly.

<html>
<head>
<style type="text/css">
<!--
body { background-color: #333 }
.imgdiv { float: left; margin: 4px }
.textdiv { background-color: #009; margin: 8px; padding: 5px; float:
left; width: auto; color: fff; }
-->
</style>
</head>
<body>
<div class="imgdiv">
<img src="foo.jpg" height="283" width="360" />
</div>
<div class="textdiv" >
<p>I would like this area to line up with the top of this div even
with the top of the foo.jpg image, and extending from just to the
right of the foo.jpg image, all the way to the right edge of the
browser. It shows up as I want in IE 6.0, but in Netscape 7.x or FF
1.x it shows up UNDER the image, extending across the width of the
browser window.</p>
</div>
</body>
</html>


Don't float the .textdiv, only give it a left margin of 368px.
Or, if you want the text to continue below the pic if the text might
be long enough, do nothing. No margin, no float. (except for the float
on the image of course)

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 21 '05 #4
day
On Mon, 23 May 2005 15:24:43 +0200, Els <el*********@ti scali.nl>
wrote:
Don't float the .textdiv, only give it a left margin of 368px.
Or, if you want the text to continue below the pic if the text might
be long enough, do nothing. No margin, no float. (except for the float
on the image of course)


I see what you mean, but I want the .textdiv to be as wide or as
narrow as the browser window and the occupied space to its left allow
(because I'd like to use that class for divs that appear to the right
of other content as well, that may be wider or narrower).
Jul 21 '05 #5
day <Da*@theraces.i nvaliddomain> wrote:
As per usual an uploaded example is worth a thousand words, your
description contains contradictions and lacks essential information.

Is this what you are after?:
http://homepage.ntlworld.com/spartanicus/day.htm

or do you want a "column" layout?
Thanks, good point.


You haven't answered the question I put to you.
The following html is a stripped-down segment
from something I'm doing, that illustrates the issue perfectly.


No it doesn't. If you want a certain layout then create a line drawing
or something like that. Don't assume that people have access to IE, if
you want help don't expect people to open up their editor, copy and
paste your code, save it and then display it in a browser, *upload* it
and post the url.

--
Spartanicus
Jul 21 '05 #6
Els
day wrote:
On Mon, 23 May 2005 15:24:43 +0200, Els <el*********@ti scali.nl>
wrote:
Don't float the .textdiv, only give it a left margin of 368px. Or,
if you want the text to continue below the pic if the text might
be long enough, do nothing. No margin, no float. (except for the
float on the image of course)


I see what you mean, but I want the .textdiv to be as wide or as
narrow as the browser window and the occupied space to its left
allow (because I'd like to use that class for divs that appear to
the right of other content as well, that may be wider or narrower).


So you are floating the text div because you don't know how wide the
img div may become, right? I don't think you can do that, unless you
find a way to dynamically determine the width of the imgdiv, and use
that as the left-margin of the textdiv.
Floats can't "take up the rest of the space". (or at least not in all
browsers)

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Jul 21 '05 #7
day
On Mon, 23 May 2005 14:37:17 GMT, Spartanicus
<in*****@invali d.invalid> wrote:
day <Da*@theraces.i nvaliddomain> wrote:
As per usual an uploaded example is worth a thousand words, your
descriptio n contains contradictions and lacks essential information.

Is this what you are after?:
http://homepage.ntlworld.com/spartanicus/day.htm

or do you want a "column" layout?


Thanks, good point.


You haven't answered the question I put to you.
The following html is a stripped-down segment
from something I'm doing, that illustrates the issue perfectly.


No it doesn't. If you want a certain layout then create a line drawing
or something like that. Don't assume that people have access to IE, if
you want help don't expect people to open up their editor, copy and
paste your code, save it and then display it in a browser, *upload* it
and post the url.


I don't want a column layout. I want a variable-width div that will
occupy whatever "remaining" space there is on the right side of a
browser window. The html snippet above illustrates what I'm doing,
although, yes, it would be nice to see it in IE to see what I'm trying
to do. Let me attempt a line drawing:

---------------------- ----------------------------------------------
| some content | | text div fills out remainder of screen|
---------------------- ----------------------------------------------

-------- ------------------------------------------------------------
| slim | | so the text div (same class) is wider = = = = = |
-------- ------------------------------------------------------------

---------------------------- ----------------------------------------
| content wider now | | so the text div narrows = = = |
---------------------------- ----------------------------------------

Upthread, Els says that floats can't "take up the rest of the space"
at least not in all browsers. And that's what I'm trying to do,
without the use of php or something like that. I want the divs on the
right, all the same class, to go out to the edge of the browser
window, no matter how much space is taken up to their left.

How's that description?
Jul 21 '05 #8
day <Da*@theraces.i nvaliddomain> wrote:
I don't want a column layout. I want a variable-width div that will
occupy whatever "remaining" space there is on the right side of a
browser window.


The example I uploaded provides the described layout, did you bother to
look at it?

--
Spartanicus
Jul 21 '05 #9
day
On Mon, 23 May 2005 15:23:03 GMT, Spartanicus
<in*****@invali d.invalid> wrote:
day <Da*@theraces.i nvaliddomain> wrote:
I don't want a column layout. I want a variable-width div that will
occupy whatever "remaining" space there is on the right side of a
browser window.


The example I uploaded provides the described layout, did you bother to
look at it?


I *did* look at it when you first posted it. Thanks. My first
thought was that it wouldn't work for what I was trying to do, but I
looked further at it and think I can adapt a couple other assumptions
I 'd made and implement as you did in the example. It will look fine,
and it's better than trying to figure out how to make a class that can
be variable width.
Jul 21 '05 #10

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

Similar topics

8
33899
by: Mario T. Lanza | last post by:
I'm not sure what I'm doing wrong. I have a form that has mnay input fields. Before each input field is a label enclosed in custom LABEL tags. Inside my CSS I have: LABEL { width: 120px; }
17
27867
by: Piers Lawson | last post by:
If the following is displayed in IE6 or FireFox, the text box forces the second DIV to expand beyond its 15em width. Is there a way to have the text box fit within the DIV (preferably without losing its default borders)? Thank you in advance Piers <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
2
16633
by: Georg Goerg | last post by:
hello, i want to make website with a top navigation bar and one on the left. so by using css i define three layers and everyone of them has length attr. in percents. but if i want to put (square) images in e.g. the top bar, which should fill out the whole height of the bar, it depends on the screen resolution, wether they look like square images or rectangles.
8
10635
by: Lian | last post by:
Hi all, It is a newbie's question about html tag "img". The attributes "title" and "alt" for "img" seems having the same function. So what is the main difference between them? Can i use them at the same time and set different values? Thank you for suggestions!
15
122115
by: Gérard Talbot | last post by:
Hello all, I'd like to know and understand the difference between, say, <img src="/ImageFilename.png" width="123" height="456" alt=""> and <img src="/ImageFilename.png" style="width: 123px; height: 456px;" alt="">
50
6035
by: Shadow Lynx | last post by:
Consider this simple HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Strict kills my widths!</title> </head> <body> <table style="width:400px; table-layout:fixed;">
1
8012
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL: http://(address.of.my.webcam):port/LiveView.html and
16
4467
by: Tantale | last post by:
I used this serviec to check my webpage http://www.jmrw.com/Abroad/Barcelone/index.htm Made with Dreamweaver 8. The result is 206 errors, most of them "end tag omitted, but OMITTAG NO was specified.". I don't understand this result. Should I modify something ? Thanks
3
4255
by: shapper | last post by:
Hello, I defined the width of a form input as follows: fieldset input {width: 24em;} But then the checkbox inputs also get a width. So I uses the following: <input name="IsPublished" id="IsPublished" type="checkbox"
0
7880
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8255
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
8010
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
6665
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
5739
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
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2389
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
1
1486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1217
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.