css语法规则屏幕自适应及条目应用优先权
2015-04-05 23:41
344 查看
1.
!important 提升指定样式条目的应用优先权。
div {
color: #f00 !important;
color: #000;
}
在上述代码中,IE6及以下浏览器div的文本颜色为#000,!important并没有覆盖后面的规则;其它浏览器下div的文本颜色为#f00
2.可以让屏幕自适应的方法:
/* 样式代码导入 样式文件 */
第一种方式:
<link media="screen and (width:800px)" rel="stylesheet" href="style/css800.css">
<link media="screen and (width:1280px)" rel="stylesheet" href="style/css1280.css">
<link media="screen and (width:1440px)" rel="stylesheet" href="style/css1440.css">
第二种方式:
<style>
@import url(style/css800.css) screen and (min-width:800px);
@import url(style/css1280.css) screen and (min-width:1280px);
@import url(style/css1440.css) screen and (min-width:1440px);
</style>
如下为css800.css的代码
如下为css1280.css的代码
如下为css1440.css的代码
第三种方式:
!important 提升指定样式条目的应用优先权。
div {
color: #f00 !important;
color: #000;
}
在上述代码中,IE6及以下浏览器div的文本颜色为#000,!important并没有覆盖后面的规则;其它浏览器下div的文本颜色为#f00
2.可以让屏幕自适应的方法:
/* 样式代码导入 样式文件 */
第一种方式:
<link media="screen and (width:800px)" rel="stylesheet" href="style/css800.css">
<link media="screen and (width:1280px)" rel="stylesheet" href="style/css1280.css">
<link media="screen and (width:1440px)" rel="stylesheet" href="style/css1440.css">
第二种方式:
<style>
@import url(style/css800.css) screen and (min-width:800px);
@import url(style/css1280.css) screen and (min-width:1280px);
@import url(style/css1440.css) screen and (min-width:1440px);
</style>
如下为css800.css的代码
1 #container{ 2 width:760px; 3 height:300px; 4 border:1px solid red; 5 background-color:red; 6 }
如下为css1280.css的代码
#container{ width:1004px; height:300px; border:1px solid red; background-color:red; }
如下为css1440.css的代码
1 #container{ 2 width:1320px; 3 height:300px; 4 border:1px solid red; 5 background-color:red; 6 }
第三种方式:
*{ margin:0; border:0; padding:0; } #container{ width:1240px; height:300px; background-color:red; margin:0 auto; } /* 当屏幕的分辨率宽度小于等于1260px时,执行如下样式代码 */ @media (max-width:1260px) { #container{ width:930px; background-color:green; } } /* 当屏幕的分辨率宽度小于等于800px时,执行如下样式代码 */ @media (max-width:800px) { #container{ width:760px; background-color:blue; } } </style>
相关文章推荐
- css-!important-提升指定样式规则的应用优先权。
- CSS规则层叠的应用
- CSS规则层叠的应用 css必须要注意的几点
- html css div自适应屏幕宽度,高度
- CSS web页面自适应屏幕
- andorid最新的不规则色彩背景图片自适应屏幕宽高,背景不变形
- CSS 结构和规则 [ 基本语法 | 伪类别和伪元素 | 层叠顺序 ]
- 常用CSS缩写规则语法
- HTML、CSS和JavaScript学习三(JavaScript之语法规则:语句、数组、函数、String\Math\Array等对象)
- CSS中优先权计算规则详解(转载)
- 如何通过CSS实现背景图片自动平铺或拉伸至整个屏幕(自适应大小)
- CSS规则层叠的应用
- CSS中优先权计算规则详解
- CSS基础语法规则学习笔记
- css的position属性 居中 宽度自适应屏幕
- CSS规则层叠的应用 css必须要注意的几点
- CSS语法缩写规则,减少CSS文件的大小【转帖】
- .htaccess的重写规则 .htaccess基本语法和应用
- html css div自适应屏幕宽度,高度
- 独行DIV自适应宽度布局CSS实例与应用范围