CSS权威指南-候选样式表

来源:互联网 发布:虚拟专用网vpn 软件 编辑:程序博客网 时间:2024/06/03 20:04

候选样式表, 就是允许为一个页面提供多种风格的样式表,用户在浏览该页面时可以选择自己喜欢的页面风格.

将rel属性的值设置为alternate stylesheet,只有在用户选择这个样式表时才会用于文档表现。

具体做法通过下面一个例子来说明:

css部分:
1.css

.red{    width:200px;    height:200px;    background-color: red;}
2.css

.red{    width:200px;    height:200px;    background-color: yellow;}

HTML部分:

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title></title>    <link rel="stylesheet" type="text/css" href="1.css" title="red">    <link rel="alternate stylesheet" type="text/css" href="2.css" title="yellow"></head><body> <div class="red"></div></body></html>



我只有在Firefox和IE上使用成功,其他浏览器都找不到页面样式在哪!

为候选样式表指定同样的title值,把它们分组在一起。

只要打开或刷新页面,页面都会恢复到首选样式表的状态。

rel设置为stylesheet,并且没有属性title,那么它将作为一个永久样式表。

如果rel都设置为stylesheet,并且都设置了title,那么只有一个会真正做为首选样式表,是哪一个由浏览器决定。


0 0
原创粉丝点击