CSS:根据屏幕分辨率,使用不同的宽度 [英] CSS: Using different width depending on screen resulution

查看:273
本文介绍了CSS:根据屏幕分辨率,使用不同的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下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>

是否可以根据屏幕分辨率为mainleftcenterright定义不同的宽度.例如,如果屏幕分辨率为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:根据屏幕分辨率,使用不同的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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