473,405 Members | 2,279 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,405 software developers and data experts.

How to achieve IE's (non-compliant) behaviour compliantly?

Hi,

I have a class for buttons which relies on IE's misinterpretation of
"overflow: visible" to set a minimum width - I.E. will automatically
horizontally expand any buttons whose text doesn't fit. This is
exactly the behaviour I want, but is non-standard, and Firefox simply
truncates the text (actually I thought it was supposed to spill outside
the button, but either way is useless).

I've tried using min-width under Firefox to get the same effect, but
with min-width it seems there is no way of centering the text
horizontally. Even if you do:

<button style="min-width:10em"><div
style="width:100%;background:red">Test</div></button>

You can see that the inner div is only the width of the word 'Test'.
In other words, it's as though "min-width" always adds padding to the
right to the parent control, instead of expanding the content area.

The same problem occurs with elements other than 'button' - in fact any
element that is normally an inline element has the same issue. Only
elements like DIV etc. that are normally block elements behave as I
expect here (I embedded a div in a table to test the effect of
min-width). Marking the button as a block element doesn't help.

Note sure if this is a Firefox issue, or a misunderstanding of the CSS
specs, but it seems crazy there's no way to do this. For the time
being I guess I won't bother with the minimum width under Firefox,
which means *all* my buttons are different sizes, as opposed to an
exceptional few with extra long text. And for hopefully obvious
reasons, I don't want to use one class for buttons with "short text"
and another for ones with "long text"; if nothing else, the pages are
intended to work in other languages in the future, but even if not it's
a maintenance headache anyway.

Dec 12 '06 #1
3 3136
On 2006-12-12, wi******@hotmail.com <wi******@hotmail.comwrote:
Hi,

I have a class for buttons which relies on IE's misinterpretation of
"overflow: visible" to set a minimum width - I.E. will automatically
horizontally expand any buttons whose text doesn't fit. This is
exactly the behaviour I want, but is non-standard, and Firefox simply
truncates the text (actually I thought it was supposed to spill outside
the button, but either way is useless).

I've tried using min-width under Firefox to get the same effect, but
with min-width it seems there is no way of centering the text
horizontally. Even if you do:

<button style="min-width:10em"><div
style="width:100%;background:red">Test</div></button>

You can see that the inner div is only the width of the word 'Test'.
In other words, it's as though "min-width" always adds padding to the
right to the parent control, instead of expanding the content area.
This does look like a Firefox issue. button is supposed to be display:
inline-block by default, which Firefox doesn't really support. But it
does allow you to set width and min-width on a button (which you can do
on inline blocks, but not on inlines), so there's some partial support
there. But if button really were proper display: inline-block then your
red background would extend to the whole width of the button.
The same problem occurs with elements other than 'button' - in fact any
element that is normally an inline element has the same issue. Only
elements like DIV etc. that are normally block elements behave as I
expect here (I embedded a div in a table to test the effect of
min-width). Marking the button as a block element doesn't help.

Note sure if this is a Firefox issue, or a misunderstanding of the CSS
specs, but it seems crazy there's no way to do this.

For the time being I guess I won't bother with the minimum width under
Firefox, which means *all* my buttons are different sizes, as opposed
to an exceptional few with extra long text. And for hopefully obvious
reasons, I don't want to use one class for buttons with "short text"
and another for ones with "long text"; if nothing else, the pages are
intended to work in other languages in the future, but even if not
it's a maintenance headache anyway.
So you want most of the buttons to have width set on them, the text
centered in those buttons, and buttons with exceptionally wide contents
to get a bit wider?

How about

<button>
<div style="min-width: 10em; text-align: center">
OK
</div>
</button>

This seems to work for me in as it should in Firefox.
Dec 13 '06 #2

Ben C wrote:

For the time being I guess I won't bother with the minimum width under
Firefox, which means *all* my buttons are different sizes, as opposed
to an exceptional few with extra long text. And for hopefully obvious
reasons, I don't want to use one class for buttons with "short text"
and another for ones with "long text"; if nothing else, the pages are
intended to work in other languages in the future, but even if not
it's a maintenance headache anyway.

So you want most of the buttons to have width set on them, the text
centered in those buttons, and buttons with exceptionally wide contents
to get a bit wider?

How about

<button>
<div style="min-width: 10em; text-align: center">
OK
</div>
</button>

This seems to work for me in as it should in Firefox.
Hmm, thanks, but it's hardly elegant - I have a *lot* of buttons!
Guess it will do for now.

Dec 14 '06 #3
wi******@hotmail.com wrote:
I have a class for buttons which relies on IE's misinterpretation of
"overflow: visible" to set a minimum width - I.E. will automatically
horizontally expand any buttons whose text doesn't fit. This is
exactly the behaviour I want, but is non-standard, and Firefox simply
truncates the text (actually I thought it was supposed to spill outside
the button, but either way is useless).
Useless is right. A possible solution is here:

http://www.simple-nude.com/button-like-div.html

Please ignore the extraneous borders in the examples.

Because of the frustrations I've had with buttons, I just don't use
them anymore. Instead, I use divs that appear and act like buttons.
Maybe you can use some of the ideas on the solution page. The main
things are to (1) make sure the entire surface of the div is
selectable; and (2) get min-width to treat the button label properly.

HTH.

-- fredo

Dec 18 '06 #4

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

Similar topics

45
by: Jordan Rastrick | last post by:
Can anybody please give me a decent justification for this: class A(object): def __init__(self, a): self.a = a def __eq__(self, other): return self.a == other.a s = A(3)
14
by: JKop | last post by:
class Cow { public: void EatGrass() const {} }; class Brow { private:
6
by: Jim Lawton | last post by:
I am trying to achieve a simple page layout using only divs and css. I know that people bad mouth IE for non-conformance, but in this case IE's(6.0)behaviour is entirely the way I expect, and Gecko...
9
by: Christian Eder | last post by:
Hi, I think I have discovered a problem in context of metaclasses and multiple inheritance in python 2.4, which I could finally reduce to a simple example: Look at following code: class...
4
by: Mikael Olofsson | last post by:
Hi! This is in Python 2.3.4 under WinXP. I have a situation where I think changing the behaviour of a namespace would be very nice. The goal is to be able to run a python file from another in...
68
by: stasgold | last post by:
Hello. I maybe reinvent the weel ... I'm trying to read positive integer number with the help of scanf, if the input value is not positive number but negaive one zero or char , i have to reread...
3
by: asadikhan | last post by:
Hi, I have written a windows application with a GUI (let's call it MENU). I own the code for this application and have access to it. We have another application that is a third-part windows...
7
by: jacek.dziedzic | last post by:
Hello! Can someone tell me what the expected output of the following program is? #include <fstream> #include <iomanip> using namespace std;
285
by: Sheth Raxit | last post by:
Machine 1 : bash-3.00$ uname -a SunOS <hostname5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R bash-3.00$ gcc -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/...
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...
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...
0
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...
0
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,...
0
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...

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.