如果我设置最小高度和最大高度,哪一个优先? [英] If I set min-height and max-height, which one has priority?
问题描述
我有一个菜单,有9个项目。我希望按钮高度具有40px或11%(屏幕的1/9)的屏幕尺寸。什么是最大的。
现在我有:
min-height:40px;
最大高度:11%;
总是40px。即使我的屏幕尺寸比这大。
我可以在css上实现这一目标吗?或者我必须使用javascript?
谢谢。
编辑
JSFiddle 。
@Jeffery Khan是对的,解决了它。我有一个不同的元素推动它。谢谢!
min-height
一些东西被设置为除非某些东西导致它扩大,例如div的内容。
请尝试以下操作:
min-height:40px;
身高:11%;
I have a menu, with 9 items. I want the button height to have 40px OR 11%(1/9 of the screen) of the screen size. Whathever is the largest.
Right now i have:
min-height:40px;
max-height:11%;
And it's always 40px. Even when my screensize is larger than that.
Can I achieve that on css or I have to use javascript?
Thank you.
EDIT
JSFiddle for it.
@Jeffery Khan is right, that solves it. I had a different element pushing it up. Thank you!
min-height
is generally the height of whatever something is set to unless something causes it to expand passed that, such as the contents of a div.
Try the following:
min-height:40px;
height:11%;
这篇关于如果我设置最小高度和最大高度,哪一个优先?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!