问题描述
我具有以下HTML文档结构:
I have following structure of an HTML document:
<body>
<div class="main">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
<div>
</body>
是否可以根据屏幕分辨率为main
,left
,center
和right
定义不同的宽度.例如,如果屏幕分辨率为1280或更高,则主宽度应为1140px.如果小于或等于1280,则宽度应为960px?谢谢.
Is it possible to define different width for the main
, left
, center
and right
depending on the screen resulation. For example if the screen resulution is 1280 or higher, main width should be 1140px. If it is 1280 or lower, the width should 960px?Thanks.
PS.我知道我们可以用%定义宽度,但是我很想知道是否可以定义2种不同的固定宽度.
PS. I understand we can define the width in %, but I am interested to know if we can define 2 different fixed widths.
推荐答案
仅使用CSS,就可以使用媒体查询. 这里是规格,和一些示例.请注意,并非所有浏览器都支持此功能.
Using only CSS, you can use media queries. Here's the spec, and some examples. Note that not all browsers support this feature.
这篇关于CSS:根据屏幕分辨率,使用不同的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!