内联块+最小/最大宽度行为 [英] Inline-block + min/max-width behavior

查看:57
本文介绍了内联块+最小/最大宽度行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在许多浏览器(FF,Opera,Ie)中看到,我给它们提供了内联块"和最小/最大宽度"的元素,它们的宽度自动设置为最小宽度",而不是最大宽度,正如预期的那样.那是正常行为吗?

I see in many browsers (FF,Opera,Ie) that elements I give them "inline-block" and "min/max width" , their width is automatically sets to "min-width", and not max-width, as expected. Is that normal behavior?

我可以用CSS方式(最大宽度的内联块元素)解决它吗?(我了解floats/tables/js,出于某些原因,我需要以此方式进行操作)

Can I solve it in css way (inline-block element with max-width)? (I know about floats/tables/js, there are some reasons i need do it in this way)

这是代码

推荐答案

您遇到的是有效行为. min-width 表示宽度不能小于 min-width 值.另一方面, max-width 表示宽度不能超过 max-width 值(但可以更小).因此,如果您在一个空元素上同时指定 min-width max-width ,则其宽度将设置为 min-width .

You are encountering a valid behavior. min-width means that the width cannot be less than the min-width value. On the other hand, max-width means that the width cannot exceed the max-width value (but it can be less). Thus if you specify both min-width and max-width on an empty element, its width is set to min-width.

这篇关于内联块+最小/最大宽度行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆