CSS基础学习6-CSS设置元素的分类与标识(class和id)
2016-10-20 11:14
591 查看
所有CSS基础学习文档下载地址:http://download.csdn.net/detail/rongrong_love_lc/9663463
六、CSS设置元素的分类与标识(class和id) 1.用class对元素进行分类: value: .classname html文件如下 : <html> <head> <title>Color例子</title> <link rel="stylesheet" type="text/css" href="color.css"/> </head> <body> <p>测试信息1</p> <ul> <li><a href="https://www.baidu.com" class="green">百度一下1</a></li> <li><a href="https://www.sogou.com" class="yellow">搜狗1</a></li> <li><a href="http://translate.google.cn" class ="red">谷歌翻译1</a></li> <li><a href="http://fanyi.youdao.com" class="black">有道翻译1</a></li> </ul> <p>测试信息2</p> <ul> <li><a href="https://www.baidu.com">百度一下2</a></li> <li><a href="https://www.sogou.com">搜狗2</a></li> <li><a href="http://translate.google.cn">谷歌翻译2</a></li> <li><a href="http://fanyi.youdao.com">有道翻译2</a></li> </ul> </body> </html> CSS文件如下: body {background:white url("image1.jpg") no-repeat fixed center; } p {text-align:justify; letter-spacing:5px; text-transform:none;} a {color:blue;} .green {color:green; text-decoration:underline;} .black {color:black; text-decoration:underline;} .yellow {color:yellow; text-decoration:underline;} .red {color:red; text-decoration:underline;} 2.利用ID标识元素: value:#id(注意:每个id都必须是唯一的 html中) html文件如下: <html> <head> <title>Color例子</title> <link rel="stylesheet" type="text/css" href="color.css"/> </head> <body> <p>study测试文本信息study</p> <h1 id="a1">study测试文本信息1study</h1> <h2 id="a2">study测试文本信息2study</h2> <h3 id="a3">study测试文本信息3study</h3> </body> </html>
相关文章推荐
- css:元素的分类与标识(class和id)
- CSS基础学习10-CSS设置元素的定位
- 第七课 元素的分类与标识(class和id)
- CSS基础学习9-CSS设置浮动元素(float)
- 利用class、id对元素进行分类、标识。
- 利用class、id对元素进行分类、标识实例
- CSS基础学习7-CSS设置组织元素(span和div)
- CSS学习.0(基础知识,一般格式,class,id
- CSS学习笔记-附加篇(div中class与id的区别及应用)
- CSS学习笔记:id与class、padding和margin、min-height和height
- 移除连续重复的字符串元素 分类: python 小练习 python基础学习 divide into python 2014-01-01 15:53 392人阅读 评论(0) 收藏
- css知识笔记(一)——基础知识、选择器、元素分类
- CSS学习笔记:id与class、padding和margin、min-height和height
- JavaScript 学习笔记3 CSS的ID、CLASS简单应用
- jQuery 入门教程(16): 设置或取得元素的CSS class
- jQuery 入门教程(16): 设置或取得元素的CSS class
- 网页技术CSS元素的class与ID命名常用关键字(不断完善中,敬请关注) .
- CSS学习:常见元素分类
- DIV+CSS学习--关于ID和CLASS
- js通过标签元素id,用document.getElementById().style设置标签元素的css属性