By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,487 Members | 1,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,487 IT Pros & Developers. It's quick & easy.

Min()/max()

P: n/a
Hi!

Why doesn't CSS support primitive functions like min()/max()? Something like

blah
{
width: max(50px,20%); // 20%& but not less than 50px
}

would really often be useful..

Timo
Jul 20 '05 #1
Share this Question
Share on Google+
36 Replies


P: n/a
Timo Nentwig <tc*@spamgourmet.org> wrote:
Why doesn't CSS support primitive functions like min()/max()? Something like
Because CSS is not a programming language and therefor doesn't contain
any functions at all?
blah
{
width: max(50px,20%); // 20%& but not less than 50px
}
Sounds like,
blah {
max-width: 20%;
min-width: 50px;
}
would really often be useful..


Tell Microsoft, maybe they'll support min-width and max-width at some
point in the future. After all it's only six years since CSS2 was
published.

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

P: n/a
Timo Nentwig <tc*@spamgourmet.org> wrote:
Why doesn't CSS support primitive functions like min()/max()?

blah {
width: max(50px,20%); // 20%& but not less than 50px
}

would really often be useful..


blah {
min-width: 50px;
max-width: 20%;
}

Write to your congressman if this doesn't work in the browser
everybody uses, they all seem to be on Microsoft's payroll.
Jul 20 '05 #3

P: n/a
Steve Pugh <st***@pugh.net> wrote:
Timo Nentwig <tc*@spamgourmet.org> wrote:
Why doesn't CSS support primitive functions like min()/max()?


Because CSS is not a programming language and therefore doesn't contain
any functions at all?


Well, there are some functions actually called functions in property
declarations: url(), counter().
Jul 20 '05 #4

P: n/a
Steve Pugh wrote:
Because CSS is not a programming language and therefor doesn't contain
any functions at all?


text-transform: lowercase;
Jul 20 '05 #5

P: n/a
Steve Pugh wrote:
Sounds like,
blah {
max-width: 20%;
min-width: 50px;
}


No, sounds like min()/max(). The above is quite stupid, do you want to
invent a min-/max- for everything? min-font-size/max-font-size,
min-this/max-that?
Jul 20 '05 #6

P: n/a
Timo Nentwig <tc*@spamgourmet.org> wrote:
Steve Pugh wrote:
Sounds like,
blah {
max-width: 20%;
min-width: 50px;
}
No, sounds like min()/max().


Which don't exist.
The above is quite stupid, do you want to
invent a min-/max- for everything? min-font-size/max-font-size,
min-this/max-that?


I'm not the W3C. max-width and min-width exist in the CSS2 spec. If
you don't like them take it up with the W3C.

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 #7

P: n/a
Timo Nentwig <tc*@spamgourmet.org> wrote:
Steve Pugh wrote:
Because CSS is not a programming language and therefor doesn't contain
any functions at all?


text-transform: lowercase;


You think that's a function? You'll be telling us next that
font-weight: bold; is a function as well.

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 #8

P: n/a
Steve Pugh wrote:
Timo Nentwig <tc*@spamgourmet.org> wrote:
Why doesn't CSS support primitive functions like min()/max()?
Something like


Because CSS is not a programming language and therefor doesn't contain
any functions at all?

[snip]

Actually "50%" is, in effect, a sort-of function. It says (sort-of) find the
container width & multiply by 0.5.

I wish it went just one stage further, such as (50% - 100px), which would not
require more "knowledge" than it already had. It would make handling columns
in flexible layouts a bit easier.

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #9

P: n/a
In article <c4*************@ID-18956.news.uni-berlin.de>,
Timo Nentwig <tc*@spamgourmet.org> wrote:
Why doesn't CSS support primitive functions like min()/max()? Something like

blah
{
width: max(50px,20%); // 20%& but not less than 50px
}


A similar syntax was discussed back in the 1999-2000 time frame,
actually, having arisen from a disucssion on column layout. As I
recall, it was rejected on the grounds that such values would be
completely unreadable by browsers that didn't support range values (as
they were then called). In other words, what you have above would be
ignored by every browser on the market today. That could be something
of a problem.
We ran into similar problems for a variant syntax I came up with at
that time, which went something like this:

width: 7em+ 10em~ 15em-

....which would have made the element no less than 7em wide and no more
than 15em wide, with a preferred width of 10em. There were a lot of
fuzzy areas that never got resolved (like whether those were even the
right symbols to use, let alone what happened in the more pathological
cases) because the grammatical problems shot the whole idea down before
we got to hashing out the details of how the proposal might work.

--
Eric A. Meyer (er**@meyerweb.com) http://www.meyerweb.com/eric/
Author, "Cascading Style Sheets: The Definitive Guide,"
"Eric Meyer on CSS," "CSS 2.0 Programmer's Reference," and more
http://www.meyerweb.com/eric/books/
Jul 20 '05 #10

P: n/a
Eric A. Meyer wrote:
[snip]
We ran into similar problems for a variant syntax I came up with at
that time, which went something like this:

width: 7em+ 10em~ 15em-

...which would have made the element no less than 7em wide and no more
than 15em wide, with a preferred width of 10em. There were a lot of
fuzzy areas that never got resolved (like whether those were even the
right symbols to use, let alone what happened in the more pathological
cases) because the grammatical problems shot the whole idea down
before we got to hashing out the details of how the proposal might
work.


Were simpler variants ever discussed? The one that keeps appearing on people's
wish-list is to do very simple sums to generate a specific width, rather than
a range of widths. Even as crude as (100% - 300px), which might be the width
left after allowing for a couple of sidebars. (Wouldn't that sum be easy to do
in all cases where 100% itself could be evaluated?)

(It keeps appearing in connection with multi-column layouts. Perhaps it is
argued that using normal flow plus display:table would achieve what is needed,
but I think some people would quite like to be able to float the sidebars yet
have a different linearisation. And achieving a column effect for the variable
column using large left & right margins is not so good once that box has
dropped below the sidebars at narrow viewports).

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #11

P: n/a
"Steve Pugh" <st***@pugh.net> wrote in
comp.infosystems.www.authoring.stylesheets:
Timo Nentwig <tc*@spamgourmet.org> wrote:
Why doesn't CSS support primitive functions like min()/max()? Something like
Because CSS is not a programming language and therefor doesn't contain
any functions at all?


There's no reason a purely declarative language like CSS couldn't
have things that look like functions. I think you dismiss the intent
of the question a little too quickly.

I too have occasionally wanted that ability: "margin-left: 10% or
2em, whichever is more."
blah {
width: max(50px,20%); // 20%& but not less than 50px
}

Sounds like,
blah { max-width: 20%; min-width: 50px; }


Is there a similar way to do what I'm asking? I don't see one, but
maybe I'm missing the obvious.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #12

P: n/a
Stan Brown <th************@fastmail.fm> wrote:
"Steve Pugh" <st***@pugh.net> wrote in
comp.infosystems.www.authoring.stylesheets:
Timo Nentwig <tc*@spamgourmet.org> wrote:
Why doesn't CSS support primitive functions like min()/max()? Something like


Because CSS is not a programming language and therefor doesn't contain
any functions at all?


There's no reason a purely declarative language like CSS couldn't
have things that look like functions. I think you dismiss the intent
of the question a little too quickly.


I may well have been slightly terse. However, in general I feel that
there is always a temptation to overload a language with too many
features and the result is both bloated software and incomprensible
specifications.

I would suggest leaving CSS as a simple stylesheet language and leave
the functional work to something else, such as JavaScript. Microsoft
have already gone down this route with their expression() syntax.
Another route is to modify style properties via the DOM.

As most graphical browsers already support JavaScript this seems to be
a better use of resources than duplicating similar functionality in
CSS.

A well written stylesheet would contain declared values for non-JS
browsers and then over ride them with more complex modified values
dependent on JS calculations.

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 #13

P: n/a

"Steve Pugh" <st***@pugh.net> wrote in message
news:sb********************************@4ax.com...
Stan Brown <th************@fastmail.fm> wrote:
"Steve Pugh" <st***@pugh.net> wrote in
comp.infosystems.www.authoring.stylesheets:
Timo Nentwig <tc*@spamgourmet.org> wrote:

Why doesn't CSS support primitive functions like min()/max()? Something like
Because CSS is not a programming language and therefor doesn't contain
any functions at all?
There's no reason a purely declarative language like CSS couldn't
have things that look like functions. I think you dismiss the intent
of the question a little too quickly.


I may well have been slightly terse. However, in general I feel that
there is always a temptation to overload a language with too many
features and the result is both bloated software and incomprensible
specifications.


How is that? If a useful feature is omitted from the language or a widely
accepted common library, then, by the premise that the feature would have
been useful, programmers will often write lengthy code to produce the same
effect. And some developers on a project will be unaware of code already
written by team members to produce that effect, and will write their own. In
the worst case, the code won't even be put into its own procedures, but will
be repeated everywhere the effect is needed.

Do you know how many times I've written the equivalent of

dim a
if (x > y) then
a = x
else
a = y
end if
dim b
b = f(a)

when

dim b
b = f(max(x, y))

would have been much easier? Visual Basic, SQL, and some other language lack
this most obvious of functions. (SQL has "max" as an aggregate function
applicable to a column, but not in the form I'm discussing here.)



I would suggest leaving CSS as a simple stylesheet language and leave
the functional work to something else, such as JavaScript. Microsoft
have already gone down this route with their expression() syntax.
Another route is to modify style properties via the DOM.

As most graphical browsers already support JavaScript this seems to be
a better use of resources than duplicating similar functionality in
CSS.

A well written stylesheet would contain declared values for non-JS
browsers and then over ride them with more complex modified values
dependent on JS calculations.

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 #14

P: n/a
In article <KXUcc.299$jI6.6@newsfe1-win>,
"Barry Pearson" <ne**@childsupportanalysis.co.uk> wrote:
Eric A. Meyer wrote:
[snip]
We ran into similar problems for a variant syntax I came up with at
that time, which went something like this:

width: 7em+ 10em~ 15em-

...which would have made the element no less than 7em wide and no more
than 15em wide, with a preferred width of 10em. There were a lot of
fuzzy areas that never got resolved (like whether those were even the
right symbols to use, let alone what happened in the more pathological
cases) because the grammatical problems shot the whole idea down
before we got to hashing out the details of how the proposal might
work.
Were simpler variants ever discussed?


I don't recall anyone proposing simpler variants on that particular
concept (range values / constrained values). There weren't a whole lot
of proposals along those lines anyway. I did some quick digging earlier
and mine was the only one I could find, and that was posted on the WG's
internal list. If there was a similar proposal, public or private, I
was either looking in the wrong places or using the wrong search terms.
The one that keeps appearing on people's
wish-list is to do very simple sums to generate a specific width, rather than
a range of widths. Even as crude as (100% - 300px), which might be the width
left after allowing for a couple of sidebars. (Wouldn't that sum be easy to do
in all cases where 100% itself could be evaluated?)


That would run into the same grammar problems, I should think. Any
browser today should interpret 'width: (100%-300px);' as 'width: ;' as
per the CSS forward-compatible parsing rules, thus effectively nulling
the declaration. Even if such expressions were supported, to use them
in a real-world Web situation, you'd end up with stuff like this:

padding: 0 150px;
width: auto;
width: (100%-300px);

....and then as you started to pile on CSS or other hacks to step around
the browser bugs that already exist, the situation would quickly get--
well, pretty messy.
Personally, I wouldn't mind there being a way to introduce constraint
systems and simple expressions into CSS, but then I also think that
author-defined value aliases are a good idea. So that goes to show what
I know.

--
Eric A. Meyer (er**@meyerweb.com) http://www.meyerweb.com/eric/
Author, "Cascading Style Sheets: The Definitive Guide,"
"Eric Meyer on CSS," "CSS 2.0 Programmer's Reference," and more
http://www.meyerweb.com/eric/books/
Jul 20 '05 #15

P: n/a
Harlan Messinger wrote:
b = f(max(x, y))

would have been much easier? Visual Basic, SQL, and some other language lack
this most obvious of functions. (SQL has "max" as an aggregate function
applicable to a column, but not in the form I'm discussing here.)


But at least CSS does have important functions such as rgb(r,g,b)...
Jul 20 '05 #16

P: n/a
Eric A. Meyer wrote:
In article <KXUcc.299$jI6.6@newsfe1-win>,
"Barry Pearson" <ne**@childsupportanalysis.co.uk> wrote: [snip]
The one that keeps appearing on people's
wish-list is to do very simple sums to generate a specific width,
rather than a range of widths. Even as crude as (100% - 300px),
which might be the width left after allowing for a couple of
sidebars. (Wouldn't that sum be easy to do in all cases where 100%
itself could be evaluated?)


That would run into the same grammar problems, I should think. Any
browser today should interpret 'width: (100%-300px);' as 'width: ;' as
per the CSS forward-compatible parsing rules, thus effectively nulling
the declaration. Even if such expressions were supported, to use them
in a real-world Web situation, you'd end up with stuff like this:

padding: 0 150px;
width: auto;
width: (100%-300px);

...and then as you started to pile on CSS or other hacks to step
around the browser bugs that already exist, the situation would
quickly get-- well, pretty messy.


Yup!
Personally, I wouldn't mind there being a way to introduce
constraint systems and simple expressions into CSS, but then I also
think that author-defined value aliases are a good idea. So that
goes to show what I know.


Do you mean (for example) the ability to make an "identity declaration", or
whatever, that you could set in one place and keep re-using? Eg to give a name
for a colour, then just use that name wherever you need that colour? So you
can change it in just one place?

Yup!

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #17

P: n/a
*Timo Nentwig* <tc*@spamgourmet.org>:
Steve Pugh wrote:
max-width: 20%;
min-width: 50px;
The above is quite stupid,


CSS avoids using < and & for SGML/HTML/XML embedding reasons, see for
example the Media Queries spec. min() and max() might have been a workable
alternative, but they would have to be designed such that they could both be
applied to one box.
do you want to invent a min-/max- for everything?
min-font-size/max-font-size,


<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.

--
Ociffer, I swear to drunk, I'm not God!
Jul 20 '05 #18

P: n/a
On 6 Apr 2004 23:09:23 -0700, Karl Smith <go************@kjsmith.com>
wrote:
blah {
min-width: 50px;
max-width: 20%;
}

Curious - What happens when the viewport is smaller that 250px? In order
to be over 50px, it'd have to be more than 20% of the width... I would
suppose the last rule would prevail, and it would maintain 20% and shrink
below 50px. But that's a supposition.
Jul 20 '05 #19

P: n/a
*Timo Nentwig* <tc*@spamgourmet.org>:
Steve Pugh wrote:
max-width: 20%;
min-width: 50px;
The above is quite stupid,


CSS avoids using < and & for SGML/HTML/XML embedding reasons, see for
example the Media Queries spec. min() and max() might have been a workable
alternative, but they would have to be designed such that they could both be
applied to one box.
do you want to invent a min-/max- for everything?
min-font-size/max-font-size,


<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.

--
Ociffer, I swear to drunk, I'm not God!
Jul 20 '05 #20

P: n/a
On 6 Apr 2004 23:09:23 -0700, Karl Smith <go************@kjsmith.com>
wrote:
blah {
min-width: 50px;
max-width: 20%;
}

Curious - What happens when the viewport is smaller that 250px? In order
to be over 50px, it'd have to be more than 20% of the width... I would
suppose the last rule would prevail, and it would maintain 20% and shrink
below 50px. But that's a supposition.
Jul 20 '05 #21

P: n/a
In article Neal wrote:
On 6 Apr 2004 23:09:23 -0700, Karl Smith <go************@kjsmith.com>
wrote:
blah {
min-width: 50px;
max-width: 20%;
}

Curious - What happens when the viewport is smaller that 250px? In order
to be over 50px, it'd have to be more than 20% of the width... I would
suppose the last rule would prevail, and it would maintain 20% and shrink
below 50px. But that's a supposition.


Unfortunately min-width is used always by spec and practice, even if it
would make sence to leave that for author to decide
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #22

P: n/a
In article Neal wrote:
On 6 Apr 2004 23:09:23 -0700, Karl Smith <go************@kjsmith.com>
wrote:
blah {
min-width: 50px;
max-width: 20%;
}

Curious - What happens when the viewport is smaller that 250px? In order
to be over 50px, it'd have to be more than 20% of the width... I would
suppose the last rule would prevail, and it would maintain 20% and shrink
below 50px. But that's a supposition.


Unfortunately min-width is used always by spec and practice, even if it
would make sence to leave that for author to decide
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #23

P: n/a
In message <c5**********@ariadne.rz.tu-clausthal.de>, Christoph Paeper
<ch**************@nurfuerspam.de> writes
<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.


FWIW I think it's great that the concept has at last made it. In what
way do you think it's not intuitive?

(To my mind it seems to do exactly what it says it will, in a quite
obvious way!)

--
George Lund
Jul 20 '05 #24

P: n/a
In message <c5**********@ariadne.rz.tu-clausthal.de>, Christoph Paeper
<ch**************@nurfuerspam.de> writes
<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.


FWIW I think it's great that the concept has at last made it. In what
way do you think it's not intuitive?

(To my mind it seems to do exactly what it says it will, in a quite
obvious way!)

--
George Lund
Jul 20 '05 #25

P: n/a
George Lund <ge****@lund.co.uk> wrote:
In message <c5**********@ariadne.rz.tu-clausthal.de>, Christoph Paeper
<ch**************@nurfuerspam.de> writes
<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.


FWIW I think it's great that the concept has at last made it. In what
way do you think it's not intuitive?


Perhaps the fact that min-font-size doesn't actually set a minimum
font size except in one set of narrowly defined circumstances. Maybe
you missed the text that says:
"The two following properties are only used in conjunction with the
'text-align-last' property set to 'size'."

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 #26

P: n/a
George Lund <ge****@lund.co.uk> wrote:
In message <c5**********@ariadne.rz.tu-clausthal.de>, Christoph Paeper
<ch**************@nurfuerspam.de> writes
<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.


FWIW I think it's great that the concept has at last made it. In what
way do you think it's not intuitive?


Perhaps the fact that min-font-size doesn't actually set a minimum
font size except in one set of narrowly defined circumstances. Maybe
you missed the text that says:
"The two following properties are only used in conjunction with the
'text-align-last' property set to 'size'."

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 #27

P: n/a
In message <dh********************************@4ax.com>, Steve Pugh
<st***@pugh.net> writes
George Lund <ge****@lund.co.uk> wrote:
In message <c5**********@ariadne.rz.tu-clausthal.de>, Christoph Paeper
<ch**************@nurfuerspam.de> writes
<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.


FWIW I think it's great that the concept has at last made it. In what
way do you think it's not intuitive?


Perhaps the fact that min-font-size doesn't actually set a minimum
font size except in one set of narrowly defined circumstances. Maybe
you missed the text that says:
"The two following properties are only used in conjunction with the
'text-align-last' property set to 'size'."


oh yeah. poo

--
George Lund
Jul 20 '05 #28

P: n/a
In message <dh********************************@4ax.com>, Steve Pugh
<st***@pugh.net> writes
George Lund <ge****@lund.co.uk> wrote:
In message <c5**********@ariadne.rz.tu-clausthal.de>, Christoph Paeper
<ch**************@nurfuerspam.de> writes
<http://www.w3.org/TR/css3-text/#min-max-font-size-prop>---quite
non-intuitive.
That's sadly already a Candidate Recommendation ("which means W3C believes
the specification is ready to be implemented") and my remarks regarding the
partly ill design went almost unheard.


FWIW I think it's great that the concept has at last made it. In what
way do you think it's not intuitive?


Perhaps the fact that min-font-size doesn't actually set a minimum
font size except in one set of narrowly defined circumstances. Maybe
you missed the text that says:
"The two following properties are only used in conjunction with the
'text-align-last' property set to 'size'."


oh yeah. poo

--
George Lund
Jul 20 '05 #29

P: n/a
Lauri Raittila <la***@raittila.cjb.net> wrote:
In article Neal wrote:
On 6 Apr 2004 23:09:23 -0700, Karl Smith wrote:
blah {
min-width: 50px;
max-width: 20%;
}
Curious - What happens when the viewport is smaller that 250px? In order
to be over 50px, it'd have to be more than 20% of the width... I would
suppose the last rule would prevail, and it would maintain 20% and shrink
below 50px. But that's a supposition.


You don't need the added complication of the percentage or small
viewports for that to be an issue. There's nothing to stop someone
declaring:

example {
min-width: 20em;
max-width: 10em;
width: 50em;
}

As always, a little bit of common sense goes a long way.

Unfortunately min-width is used always by spec and practice, even if it
would make sence to leave that for author to decide.


Why "unfortunately"? Having minimum prevail seems the sensible
behaviour to me.

--
Karl Smith.
Jul 20 '05 #30

P: n/a
Lauri Raittila <la***@raittila.cjb.net> wrote:
In article Neal wrote:
On 6 Apr 2004 23:09:23 -0700, Karl Smith wrote:
blah {
min-width: 50px;
max-width: 20%;
}
Curious - What happens when the viewport is smaller that 250px? In order
to be over 50px, it'd have to be more than 20% of the width... I would
suppose the last rule would prevail, and it would maintain 20% and shrink
below 50px. But that's a supposition.


You don't need the added complication of the percentage or small
viewports for that to be an issue. There's nothing to stop someone
declaring:

example {
min-width: 20em;
max-width: 10em;
width: 50em;
}

As always, a little bit of common sense goes a long way.

Unfortunately min-width is used always by spec and practice, even if it
would make sence to leave that for author to decide.


Why "unfortunately"? Having minimum prevail seems the sensible
behaviour to me.

--
Karl Smith.
Jul 20 '05 #31

P: n/a
In article Karl Smith wrote:
Unfortunately min-width is used always by spec and practice, even if it
would make sence to leave that for author to decide.
Why "unfortunately"? Having minimum prevail seems the sensible
behaviour to me.


But there is cases, where I would have liked to make max-width override
min-width. So if there was possibility to decide that, it would be better
than nailing it

Other problem is that I can only have min-width in one unit, it would
often make sence to say min-width:100px;min-width:20em, whichever is
bigger.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #32

P: n/a
In article Karl Smith wrote:
Unfortunately min-width is used always by spec and practice, even if it
would make sence to leave that for author to decide.
Why "unfortunately"? Having minimum prevail seems the sensible
behaviour to me.


But there is cases, where I would have liked to make max-width override
min-width. So if there was possibility to decide that, it would be better
than nailing it

Other problem is that I can only have min-width in one unit, it would
often make sence to say min-width:100px;min-width:20em, whichever is
bigger.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #33

P: n/a
Lauri Raittila wrote:

Other problem is that I can only have min-width in one unit, it would
often make sence to say min-width:100px;min-width:20em, whichever is
bigger.


While we're wishing, it'd be nice to apply min or max widths to borders
or margins.

--
Brian (remove "invalid" from my address to email me)
http://www.tsmchughs.com/
Jul 20 '05 #34

P: n/a
Lauri Raittila wrote:

Other problem is that I can only have min-width in one unit, it would
often make sence to say min-width:100px;min-width:20em, whichever is
bigger.


While we're wishing, it'd be nice to apply min or max widths to borders
or margins.

--
Brian (remove "invalid" from my address to email me)
http://www.tsmchughs.com/
Jul 20 '05 #35

P: n/a
Lauri Raittila <la***@raittila.cjb.net> wrote:
Other problem is that I can only have min-width in one unit, it would
often make sense to say min-width:100px;min-width:20em, whichever is
bigger.


That's easily solved: just make sure you always set font sizes in pixels :-)

min-width: 100px;
min-width: 20em;
font-size: 5px;

I see you still like really small fonts.

--
Karl Smith.
Jul 20 '05 #36

P: n/a
Lauri Raittila <la***@raittila.cjb.net> wrote:
Other problem is that I can only have min-width in one unit, it would
often make sense to say min-width:100px;min-width:20em, whichever is
bigger.


That's easily solved: just make sure you always set font sizes in pixels :-)

min-width: 100px;
min-width: 20em;
font-size: 5px;

I see you still like really small fonts.

--
Karl Smith.
Jul 20 '05 #37

This discussion thread is closed

Replies have been disabled for this discussion.