CSS学习(一)
来源:互联网 发布:linux怎么打开vi 编辑:程序博客网 时间:2024/05/20 06:24
1. CSS简单介绍
css主要是修饰页面的样式和布局。为什么会选择css去做呢?css可以单独作为一个外部引入文件,对多个页面都可以进行修饰。
2. css的用法
selecor:要修饰的元素类型,譬如h1
declaration:修饰的样式内容,多个declaration要用';'号隔开,以分号结尾。
property:元素的属性
value:元素的值
eg1.
==================================
<html>
<head></head>
<stlyle>
h1{color:blue;font-size:12px;}
</style>
<body>
<h1>this is my first css test</h1>
</body>
</html>
==================================
该文作用的h1标签将会按照样式中的颜色和字体大小。
3. css中id和class
如果在文件中给某一些元素指定id(class)值,样式修饰时即可根据id(class)来做统一修饰。
eg2.
==================================
<html>
<head></head>
<stlyle>
#id1{color:blue;font-size:12px;}
</style>
<body>
<h1 id="id1">this is my first css test</h1>
</body>
</html>
==================================
class的使用:
eg3.
==================================
<html>
<head></head>
<stlyle>
.class1{color:blue;font-size:12px;} //针对所有元素中出现的class1起作用
h2.class1{color:red;font-size:12px;} //针对某一个元素下的class起作用
</style>
<body>
<h1 class="class1">this is my secode css test</h1>
<h2 class="class1">this is my third css test</h2>
</body>
</html>
==================================
4. 如何引用CSS
引用CSS有三种途径:
<1> 直接作用标签元素
参考以上。
<2> 内嵌引入CSS样式
参考以上,可以放在<head> <body>等位置
<3> 外部引入CSS文件
<link rel="stylesheet" type="text/css" href="mystyle.css" />
- CSS学习(一)
- CSS学习(一)
- css学习(一)
- CSS学习(一):css语法
- Css学习笔记(一)
- CSS 学习简记(一)
- css学习笔记(一)
- Css学习笔记(一)
- CSS学习笔记(一)
- css学习笔记(一)
- CSS学习笔记(一)
- CSS基础知识学习(一)
- css学习交流(一)
- css学习笔记(一)
- css学习(一)-CSS基础、css选择器
- CSS+DIV学习笔记(一)
- 基础知识--Css学习笔记(一)
- HTML、CSS学习笔记(一)
- 复制文件夹并重命名文件夹
- WebService和Rest
- atl servcie
- vfp具备汽泡提示的消息提醒程序实现
- Windows2003端口映射
- CSS学习(一)
- .Net工程资源文件访问方法
- 投影机故障处理
- perl的子程序
- AS3]Bitmap序列化(将BitmapData保存为原生Binary/ByteArray)
- ATLASSERT
- 你知道windows NT和windows 区别吗?
- XHTML 是什么?
- symbian http post 数据 中遇到的问题