为了让自己做的页面不那么难看,最近学了点 css。
一些重要的知识点与技巧汇总如下:
1、location属性:fixed、absolute、relative
2、基础点
3、盒子模型
4、颜色
5、html 引入 css
6、css 选择器与权重
7、display 属性特性
8、浮动模型
9、主流浏览器
10、margin 塌陷、margin 合并问题
实践:
<!DOCTYPE html>
<html>
<head>
<title>test-2col</title>
<meta charset="utf-8">
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.right {
position: absolute;
right: 0;
width: 100px;
height: 100px;
background-color: black;
opacity: 0.5;
}
.left {
height: 100px;
background-color: green;
margin-right: 100px;
}
</style>
</head>
<body>
<div class="right"></div>
<div class="left"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>test-nav</title>
<meta charset="utf-8">
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.nav {
list-style: none;
}
.nav::after {
content: "";
display: block;
clear: both;
}
.nav .nav-item {
float: left;
}
.nav .nav-item a {
display: inline-block;
text-decoration: none;
color: #f40;
font-weight: bold;
height: 30px;
line-height: 30px;
padding: 0 10px;
border-radius: 15px;
}
.nav .nav-item a:hover {
color: #fff;
background-color: #f40;
}
</style>
</head>
<body>
<div class="nav">
<div class="nav-item">
<a href="#">菜单</a>
</div>
<div class="nav-item">
<a href="#">菜单</a>
</div>
<div class="nav-item">
<a href="#">菜单</a>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>5circle</title>
<meta charset="utf-8">
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.wrapper {
height: 186px;
width: 380px;
position: fixed;
left: 50%;
top: 50%;
margin-top: -93px;
margin-left: -190px;
}
.c {
width: 100px;
height:100px;
border-style: solid;
border-width: 10px;
border-radius: 50%;
position: absolute;
}
.c1 {
border-color: red;
}
.c2 {
border-color: green;
margin-left: 130px;
}
.c3 {
border-color: yellow;
margin-left: 260px;
}
.c4 {
border-color: blue;
margin-left: 65px;
margin-top: 65px;
}
.c5 {
border-color: orange;
margin-left: 195px;
margin-top: 65px;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="c c1"></div>
<div class="c c2"></div>
<div class="c c3"></div>
<div class="c c4"></div>
<div class="c c5"></div>
</div>
</body>
</html>
再写这三个实例,感觉还是很好的。
ConstXiong 备案号:苏ICP备16009629号-3