473,749 Members | 2,350 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

width: auto seems to be ignoring me in Mozilla

I'm using the following in a page that I'm testing in Mozilla:

p.actionLinkBlo ck {border: 1px #000000 dashed; padding: 0.2cm; width: auto}

But the dashed border is extending to the right-edge of the screen. I
want it to only extend as far as it needs to to nicely contain the
content within (a couple of links).

Is width: auto the wrong property to do this? Is Mozilla rendering the
style wrong?
--
Bob

Jul 20 '05 #1
5 6114
Robert Downes <no**********@s ee.my.signature .com> wrote:
I'm using the following in a page that I'm testing in Mozilla:

p.actionLinkBlo ck {border: 1px #000000 dashed; padding: 0.2cm; width: auto}
Presumably this is for a print style sheet.
But the dashed border is extending to the right-edge of the screen.
Oh. What do you expect cm to mean on screen? If I hold a ruler up to
my screen will your padding really be 0.2cm? Perhaps it's a typo and
you meant 0.2em?
I want it to only extend as far as it needs to to nicely contain the
content within (a couple of links).

Is width: auto the wrong property to do this? Is Mozilla rendering the
style wrong?


You need to read http://www.w3.org/TR/CSS2/visudet.html#q6

As you can see, your formulation means that width: auto; assigns the
full width of the parent minus border and padding.

You need to set an explicit width, setting it in ems will allow you to
set it so that it adjusts to the size of the contained text.
Alternatively set explicit values for the margins and keep width:
auto;

Or you may be able to float it and omit the width. This is forbidden
in CSS2 but allowed in the proposed CSS2.1 and catered for by browser
bugs/features.

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 #2
Steve Pugh wrote:
Robert Downes <no**********@s ee.my.signature .com> wrote:

I'm using the following in a page that I'm testing in Mozilla:

p.actionLinkBlo ck {border: 1px #000000 dashed; padding: 0.2cm; width: auto}

Presumably this is for a print style sheet.


No, it is one of several optional stylesheets for display on screen.
But the dashed border is extending to the right-edge of the screen.

Oh. What do you expect cm to mean on screen? If I hold a ruler up to
my screen will your padding really be 0.2cm? Perhaps it's a typo and
you meant 0.2em?


I'm using XFree86. The monitor display area is specified in the
configuration, so DPI values can be calculated. More importantly,
Mozilla offers a DPI calibrator, (although it does require getting out a
tape-measure and measuring a rather-too-short line on the screen).

There will be non-fixed style sheets available as default.
I want it to only extend as far as it needs to to nicely contain the
content within (a couple of links).

Is width: auto the wrong property to do this? Is Mozilla rendering the
style wrong?

You need to read http://www.w3.org/TR/CSS2/visudet.html#q6

As you can see, your formulation means that width: auto; assigns the
full width of the parent minus border and padding.


Read the section you pointed to. Even using the following:

p.actionLinkBlo ck {background: #ffffff; width: auto; margin-right: auto;
border-width: 0}

I still get a box that extends to the right-edge of the screen. The
browser must be seeing that both width and margin-right are auto, and
giving width precedence, rather than making the margin as big as possible.
You need to set an explicit width, setting it in ems will allow you to
set it so that it adjusts to the size of the contained text.
Alternatively set explicit values for the margins and keep width:
auto;
Explicit width is no good. I just want an automatically-determined
minimum-width-necessary dashed border around the list of links. I find
it hard to believe something as big as CSS 2 does not offer such a setting.
Or you may be able to float it and omit the width. This is forbidden
in CSS2 but allowed in the proposed CSS2.1 and catered for by browser
bugs/features.


CSS 2.1 is not in CR yet (still haven't worked out what that means), so
Mozilla is pretty patchy on that front.

Jul 20 '05 #3
Robert Downes <no**********@s ee.my.signature .com> wrote:
Steve Pugh wrote:
Robert Downes <no**********@s ee.my.signature .com> wrote:
p.actionLinkBlo ck {border: 1px #000000 dashed; padding: 0.2cm; width: auto}


Oh. What do you expect cm to mean on screen? If I hold a ruler up to
my screen will your padding really be 0.2cm? Perhaps it's a typo and
you meant 0.2em?


I'm using XFree86. The monitor display area is specified in the
configuratio n, so DPI values can be calculated. More importantly,
Mozilla offers a DPI calibrator, (although it does require getting out a
tape-measure and measuring a rather-too-short line on the screen).


The DPI setting in Mozilla only worked on the *nix versions last I
checked, certainly changing it has never made any difference to the
display on my Windows.
You need to read http://www.w3.org/TR/CSS2/visudet.html#q6

As you can see, your formulation means that width: auto; assigns the
full width of the parent minus border and padding.


Read the section you pointed to. Even using the following:

p.actionLinkBl ock {background: #ffffff; width: auto; margin-right: auto;
border-width: 0}

I still get a box that extends to the right-edge of the screen. The
browser must be seeing that both width and margin-right are auto, and
giving width precedence, rather than making the margin as big as possible.


Yes, as that page says
"If 'width' is set to 'auto', any other 'auto' values become '0'"
and the initial value for width is always 'auto'.
You need to set an explicit width, setting it in ems will allow you to
set it so that it adjusts to the size of the contained text.
Alternatively set explicit values for the margins and keep width:
auto;


Explicit width is no good. I just want an automatically-determined
minimum-width-necessary dashed border around the list of links. I find
it hard to believe something as big as CSS 2 does not offer such a setting.


You can always use an inline element like <span> instead. If your link
text all fits on one line then everything will be fine, if not then
the padding will be a bit odd (but hey, if the text doesn't all fit on
one line then the width issue is moot).

display: table-cell; would also do what you want but isn't supported
by IE.
Or you may be able to float it and omit the width. This is forbidden
in CSS2 but allowed in the proposed CSS2.1 and catered for by browser
bugs/features.


CSS 2.1 is not in CR yet (still haven't worked out what that means), so
Mozilla is pretty patchy on that front.


Most browsers have been 'shrink wrapping' floated elements with no
width for some time. All CSS 2.1 is going to do is standardise the
already widespread behaviour.

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 #4
Steve Pugh wrote:

You can always use an inline element like <span> instead. If your link
text all fits on one line then everything will be fine, if not then
the padding will be a bit odd (but hey, if the text doesn't all fit on
one line then the width issue is moot).


I already tried the 'display: inline' setting, but the dashed border
overlapped with the content in the block beneath.
CSS 2.1 is not in CR yet (still haven't worked out what that means), so
Mozilla is pretty patchy on that front.


Most browsers have been 'shrink wrapping' floated elements with no
width for some time. All CSS 2.1 is going to do is standardise the
already widespread behaviour.


I'm just surprised there isn't a 'margin-right: maximum' setting that
would do the job. I'm glad Mozilla does its best to stick to standards,
though. It's a nightmare trying to work without knowing what is actually
supposed to appear (e.g. the awful JavaScript which was torn in two
directions and made useless IMHO).
--
Bob
London, UK
echo Mail fefsensmrrjyahe eoceoq\! | tr "jefroq\!" "@obe.uk"
Jul 20 '05 #5
Robert Downes <no**********@s ee.my.signature .con> wrote:
Steve Pugh wrote:

You can always use an inline element like <span> instead. If your link
text all fits on one line then everything will be fine, if not then
the padding will be a bit odd (but hey, if the text doesn't all fit on
one line then the width issue is moot).


I already tried the 'display: inline' setting, but the dashed border
overlapped with the content in the block beneath.


Adjust margin-top on the block below.

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

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

Similar topics

5
35083
by: Chris Stromberger | last post by:
I have a div with a width of 40em (is em cool to use for width?). The situation below applies even if width is auto or 80% or something. Inside the div I am displaying some code with <pre> tags. If the code has a very long line (wider than the div), then what's supposed to happen? IE and Mozilla do two very different things. IE expands the div to encompass the line (creating horizontal scrollbars in the browser window if nec). Mozilla...
1
13957
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the page the way I want. Does anybody know a solution for this? First of all, the code I am using: CSS ------- body {
2
11269
by: Randall Sell | last post by:
Hmmm, have now spent a day reading the entire web with no answer yet! so now resorting again to the experts... I'm trying to create a horizontal list. This is easy enough doing: <html> <head> <style type="text/css"> #legend ul { white-space: nowrap;
4
19787
by: Philipp Lenssen | last post by:
I have a site that runs in strict mode in IE6, and IE is making <td>s for simple two-digit numbers really wide. So I want to restrict it (and right-align it) by using <td class="number"> and .number { width: 10px; }. In Mozilla this works, but IE ignores this. Next to adding an invisible "0" precding one-digit numbers, what can I do to solve this?
5
12350
by: Josh Renaud | last post by:
I'm still trying to solve a problem I have experienced in Safari. This is my third post on the subject. I'm hoping someone can shed some light. The problem is that, in Safari, a table with no specified width inside a containing div with a specified width seems to break out of that div when margins are applied to the table. It seems the table's width defaults to 100% of the parent div. But when I apply left and right margins to the...
3
14493
by: phil_gg04 | last post by:
Dear CSS Experts, I want to make a textarea fill all the available width. This is something I've done before but mostly by trial and error; now I want to understand what is going on. So I try: textarea { margin-left: 0; margin-right: 0; width: auto;
1
6367
by: Simon Dean | last post by:
Hi, Im trying to learn CSS and putting a website in effect. Just getting used to DIV's and SPAN's and using the proper formatting of H1 H2 H3 etc to format HTML documents and using different stylesheets to control formatting. So far it's going pretty well, and Im just ripping up everything I knew about tables and starting with DIV's. Though I seem to be having a hell of a time working with padding and margins, then trying to realise...
2
3819
by: Jukka K. Korpela | last post by:
Sub titulo "Re: DIV borders different in IE7 when in td" scripsit Ben C: This seems to be the heart of the matter, and I'm trying to get a real discussion started, by moving the discussion to the right group (c.i.w.a.stylesheets) and changing the Subject line. It seems to me that IE 7, specifically in "standards mode" (!), misbehaves when a table cell has a declared width but the actual width
2
3894
by: Jim Carlock | last post by:
I ran into a problem a think. Either that or I overlooked something. I seem to run into this problem quite often. I fail to pinpoint the problem and it appears as a bug with mozilla browsers. Anyone willing to offer a hint or suggestion as to why the outer container retains the width of the inner container, instead of auto-clearing both sides and instead of growing to the size of the container holding everything? <div id="container"><!--...
0
8832
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
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
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
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8256
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...
0
6078
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
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
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.