Html-样式表、字体、背景图
来源:互联网 发布:html模板仿淘宝 编辑:程序博客网 时间:2024/05/16 17:10
一. 样式表
1. 行内样式:
直接在标签里面添加style属性来添加样式。(不建议使用)
如:
<div class="div1" style="width: 100px; height:
100px;background-color: red;">
2. 内部样式表:
在head添加style标签来写样式。
如:
*{
margin: 0;
padding: 0;
}
3. 外部样式表:
通过link—方式来引入外部样式表。
如:
<link rel="stylesheet" href="css/mycss.css"/>
二. 选择器
1. 标签选择器(所有的标签)
如:
div{
width: 100px;
height: 100px;
background-color: red;
}
2. 类选择器
如:
.div1{
width: 17px;
height: 20px;
background-image: url("img/1.gif");
background-position: 0px -20px;
float: left;
}
3. id选择器
如:
#div3{
background-color: red;
}
4. 交集选择器
如:
div.c2{
width: 100px;
height: 100px;
background-color: red;
}
5. 并集选择器
如:
div,p,h1{
width: 100px;
height: 100px;
background-color: green;
}
6. 后代选择器
如:
div p{
width: 100px;
height: 100px;
background-color: green;
}
7. 通配选择器:*(原子化)
如:
*{
margin: 0;
padding: 0;
}
三. 字体
1. 改变字体大小
如:
font-size: 30px;
2. 字体类型
如:
font-family: "微软雅黑","楷体";
3. 加粗
如:
font-weight: bolder;
4. 字体样式(斜体)
如:
font-style: italic;
5. 字体颜色
如:
color: red;
6. 文本对齐方式
如:
text-align: center;
7. 行高(垂直居中让行高等于当前容器的高度)
如:
line-height: 300px;
8. 字间距
如:
letter-spacing: 20px;
9. 文字加划线
underline:下划线
line-through:中划线
overline:上划线
如:
text-decoration: underline;
10. 文字缩进
如:
text-indent: 10px;
四. 背景图
1. 添加背景图
如:
background-image: url("img/star2.jpg");
2. 背景图平铺
如:
background-repeat: no-repeat;
no-repeat:不平铺
repeat-x:水平平铺
repeat-y:垂直平铺
3. 设置背景图大小
如:
background-size: 1300px 1200px;
background-size: 100% 100%;
①. 保持图片最大的属性和容器相同,剩下的截取,显示不全
如:
background-size: cover;
②. 保持图片最小的属性和容器相同,剩下的留白,保证图片完全在容器内
如:
background-size: contain;
4. 背景图偏移
如:
background-position: -27px 0px;
五. 列表(li)常用属性
1. none:无风格
如:
list-style: none;
结果:
2. disc:实心圆(<ul>默认样式)
如:
list-style: disc;
结果:
3. circle:空心圆
如:
list-style: circle;
结果:
4. square:实心正方形
如:
list-style: square;
结果:
5. decimal:数字(<ol>默认样式)
如:
list-style: decimal;
结果:
详细请查看我的笔记:
http://note.youdao.com/noteshare?id=fbde2466c04383d8ed0055648a8454b0&sub=982F3BF3CE8544088EB91C1AA562727D
- Html-样式表、字体、背景图
- 【html】css字体样式
- HTML字体样式
- 第七节 Html字体样式
- 【HTML 字体颜色和样式】
- html/CSS 字体样式表 font-family:中文字体的英文名称
- HTML 对字体的样式的选择
- css+html中字体样式改变
- HTML巩固练习之字体样式
- 样式表中的字体
- css3 背景图 边框样式
- CSS列表 背景图样式
- HTML笔记(HTML样式简介,字体基于内容的样式与物理样式、字符实体)
- HTML背景图的显示
- html背景图自适应
- HTML背景图铺满页面
- 背景图及链接应用样式
- Android TextView使用HTML处理字体样式、显示图片等
- 菜单栏编程
- 开始写文谋生
- Mybatis中 # 和 $ 的区别
- redis的安装与使用
- webstorm进行VisualSVN配置及上传项目到项目库
- Html-样式表、字体、背景图
- (转)李开复的美东AI见闻
- hadoop2.2.0集群的高可用配置
- SDUT-3106 小鑫数数儿
- 文本编程:模仿卡拉OK文本变色
- Hadoop基础教程-第7章 MapReduce进阶(7.2 MapReduce工作机制)(草稿)
- linux 文件压缩解压
- 在Linux Opensuse42.2上使用dnw向Tiny6410下载程序
- 文本编程:模仿记事本