第009讲 初识css 类选择器 id选择器 html选择器
2015-06-17 21:46
711 查看
CSS 的基本语法:
选择器{ 属性1:属性值; 属性2:属性值; ... }
例:
a.html <html> <head> <!--引入CSS,外联--> <link rel="stylesheet" type="text/css" href="my.css"> </head> <body> <!--span元素通常用于存放小块内容--> <span class="s1">栏目一</span><br/> <span class="s2">栏目二</span><br/> <span class="s3">栏目三</span><br/> <span class="s4">栏目四</span><br/> <span class="s5">栏目五</span> </body> </html>
my.css /* .s1 用术语叫 类选择器 */ .s1{ color:green; font-size:30px; } .s2{ color:yellow; front-size:12px; } .s3{ color:blue; font-style:italic; } .s4{ color:green; font-weight:bold; } .s5{ color:#9c3131; }
滤镜技术:
<html> <head> <!--内链CSS--> <style type="text/css"> <!--变灰--> a:link img{ filter:gray; } <!--悬停--> a:hover img{ filter:"" } </style> </head> <body> <a href="3"><img src="a.jpg"/></a> </body> </html>
CSS 中常用的选择器:
类选择器(class 选择器):
基本结构: .类选择器{ 属性名:属性值; ... }
id 选择器:
基本结构: #id{ 属性名:属性值; ... }
html元素选择器:
基本结构: 某html元素{ 属性名:属性值; ... }
b.html <html> <head> <link rel="stylesheet" type="text/css" href="b.css"> </head> <body> 上海欢迎你!<br/> <span class="s1">新闻一</span> <span class="s1">新闻二</span> <span class="s1">新闻三</span> <span class="s1">新闻四</span> <span class="s1">新闻五</span><br/><br/> <span id="id1">这是一则非常重要的新闻</span> </body> </html>
b.css .s1{ background-color:pink; font-weight:bold; font-size:16px; } /* id 选择器的使用*/ #id1{ background-color:gray; font-size:40px; color:black; } body{ color:orange; }
4. 通配符选择器:
相关文章推荐
- 用css制作带三角矩形
- MFC 控件字体样式和颜色设置
- CSS技巧: CSS隐藏文字的方法(CSS text-indent: -9999px;)
- css之选择器
- 自定义新浪微博分享按钮样式
- css 指针
- css背景图片、隐藏、指针、垂直居中、去除下划线、缩进、列表类型
- CSS基础知识学习笔记
- 获取元素的外部样式问题
- CSS 100% height with padding/margin
- css postion
- css实现三角
- CSS响应式web设计
- 不同版本安卓控件的样式统一
- div+css不间断滚动字幕
- [学习记录][css]position
- 关于 css padding 的使用 padding会将使用该属性的元素撑开
- CSS Font知识整理总结
- POI简易帮助文档--给Excel设置样式
- CSS3 制作Drop Shadow效果