圆角边框原理
圆角边框的使用
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.yuan {
width: 200px;
height: 200px;
background-color: rgb(255, 166, 166);
/* border-radius: 100px; */
/* 50%就是宽度和高度的一半 */
border-radius: 50%;
}
.yj {
width: 400px;
height: 200px;
background-color: rgb(255, 166, 166);
border-radius: 100px;
}
.bt {
width: 400px;
height: 200px;
background-color: pink;
border-radius: 10px 40px 70px 100px;
}
</style>
</head>
<body>
<h4>1.圆形的做法</h4>
<div class="yuan"></div>
<h4>2.圆角矩形的做法</h4>
<div class="yj"></div>
<h4>3.可以设置不同的角</h4>
<div class="bt"></div>
</body>
</html>
盒子阴影
.box:hover {
box-shadow: 10px 10px 10px 10px rgb(145, 144, 144);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
body {
background-color: #f5f5f5;
}
.box {
width: 351px;
height: 452px;
background-color: #fff;
/* 让块级盒子水平居中 */
margin: 100px auto;
}
.name {
/* padding: 0; */
font-size: 17px;
}
a {
text-decoration: none;
color: black;
}
.review {
padding-top: 5px;
color: #b0b0b0;
font-size: 10px;
}
.v {
padding-top: 27px;
}
.v span {
color: #ff7f00;
font-size: 14px;
}
.v h4 {
display: inline-block;
color: #b0b0b0;
font-weight: 400;
font-size: 14px;
}
em {
font-style: normal;
color: #ebe4e0;
margin-left: 20px;
margin-right: 7px;
}
.box:hover {
box-shadow: 10px 10px 10px 10px rgb(145, 144, 144);
}
</style>
</head>
<body>
<a href="#">
<div class="box" align="center">
<img src="images/手机.jpg" alt="">
<p class="name">Xiaomi MIX 4</p>
<div class="review">CPU全面屏</div>
<div class="v">
<h4>小米手机...</h4>
<em>|</em>
<span>4999元起</span>
</div>
</div>
</a>
</body>
</html>
鼠标在图片上的阴影效果
文字阴影
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
color: rgb(255, 136, 0);
font-size: 50px;
font-weight: 700;
text-shadow: 5px 5px 5px rgba(0, 0, 0, .3);
}
</style>
</head>
<body>
<div>你是阴影,我是火影</div>
</body>
</html>
1.浮动
1.1传统网页布局的三种方式
1.2标准流(普通流/文档流) 1.3为什么需要浮动?
1.4什么是浮动?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.left {
float: left;
width: 200px;
height: 200px;
background-color: rgb(224, 24, 24);
}
.right {
float: right;
width: 200px;
height: 200px;
background-color: rgb(57, 255, 238);
}
</style>
</head>
<body>
<div class="left">左青龙</div>
<div class="right">右白虎</div>
</body>
</html>
1.5浮动特性(重难点)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1 {
float: left;
width: 100px;
height: 100px;
background-color: rgb(224, 24, 24);
}
.box2 {
width: 200px;
height: 200px;
background-color: rgb(57, 255, 238);
}
</style>
</head>
<body>
<div class="box1">会浮动的盒子</div>
<div class="box2">标准流的盒子</div>
</body>
</html>
浮动练习1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 1200px;
height: 640px;
background-color: rgb(255, 230, 0);
margin: 0 auto;
}
.left {
float: left;
width: 230px;
height: 640px;
background-color: rgb(30, 160, 138);
}
.right {
float: right;
width: 970px;
height: 640px;
background-color: rgb(221, 19, 80);
}
</style>
</head>
<body>
<div class="box">
<div class="left">左侧</div>
<div class="right">右侧</div>
</div>
</body>
</html>
浮动布局练习2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.box {
width: 1226px;
height: 285px;
background-color: rgb(190, 236, 22);
margin: 0 auto;
}
.box li {
width: 296px;
height: 285px;
background-color: rgb(231, 48, 48);
float: left;
margin-right: 14px;
}
/* 这里注意权重 */
.box .last {
margin-right: 0px;
}
</style>
</head>
<body>
<ul class="box">
<li>1</li>
<li>2</li>
<li>3</li>
<li class="last">4</li>
</ul>
</html>
浮动练习-手机模块
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 1226px;
height: 615px;
background-color: rgb(231, 229, 67);
margin: 0 auto;
}
.left {
width: 234px;
height: 615px;
background-color: rgb(26, 207, 192);
float: left;
}
.right {
width: 992px;
height: 615px;
background-color: rgb(145, 216, 31);
float: right;
}
.right>div {
width: 234px;
height: 300px;
background-color: #fff;
float: left;
margin-left: 14px;
margin-bottom: 14px;
background-color: rgb(247, 255, 131);
}
</style>
</head>
<body>
<div class="box">
<div class="left">左青龙</div>
<div class="right">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
</div>
</div>
</body>
</html>
2.1常见网页布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.top {
height: 50px;
background-color: rgb(180, 180, 180);
}
.banner {
width: 980px;
height: 95px;
background-color: rgb(187, 184, 184);
margin: 10px auto;
}
.box {
width: 980px;
height: 300px;
background-color: rgb(155, 151, 151);
margin: 10px auto;
}
.box li {
float: left;
width: 237px;
height: 300px;
background-color: rgb(214, 55, 55);
list-style: none;
margin-right: 10px;
}
.box .last {
margin-right: 0px;
}
/* 只要是通栏的盒子和浏览器一样宽,不需要指定宽度 */
.fotter {
height: 50px;
background-color: rgb(170, 162, 162);
}
</style>
</head>
<body>
<div class="top">top</div>
<div class="banner">banner</div>
<div class="box">
<ul>
<li></li>
<li></li>
<li></li>
<li class="last"></li>
</ul>
</div>
<div class="fotter">fotter</div>
</body>
</html>
清除浮动
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 800px;
margin: 0 auto;
border: 1px solid blue;
}
.damao {
float: left;
width: 200px;
height: 300px;
background-color: rgb(221, 68, 68);
}
.ermao {
float: left;
width: 200px;
height: 200px;
background-color: rgb(46, 179, 172);
}
.footer {
width: 500px;
height: 200px;
background-color: rgb(196, 53, 224);
}
</style>
</head>
<body>
<div class="box">
<div class="damao">大毛</div>
<div class="ermao">二毛</div>
</div>
<div class="footer"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 800px;
margin: 0 auto;
border: 1px solid blue;
}
.damao {
float: left;
width: 200px;
height: 300px;
background-color: rgb(221, 68, 68);
}
.ermao {
float: left;
width: 200px;
height: 200px;
background-color: rgb(46, 179, 172);
}
.footer {
width: 800px;
height: 200px;
background-color: rgb(196, 53, 224);
}
.clear {
clear: both;
}
</style>
</head>
<body>
<div class="box">
<div class="damao">大毛</div>
<div class="ermao">二毛</div>
<--这个新增元素要求必须是块级元素,不能是行内元素-->
<div class="clear"></div>
</div>
<div class="footer"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
overflow: hidden;
width: 800px;
margin: 0 auto;
border: 1px solid blue;
}
.damao {
float: left;
width: 200px;
height: 300px;
background-color: rgb(221, 68, 68);
}
.ermao {
float: left;
width: 200px;
height: 200px;
background-color: rgb(46, 179, 172);
}
.footer {
width: 800px;
height: 200px;
background-color: rgb(196, 53, 224);
}
.clear {
clear: both;
}
</style>
</head>
<body>
<div class="box">
<div class="damao">大毛</div>
<div class="ermao">二毛</div>
<!-- <div class="clear"></div> -->
</div>
<div class="footer"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.clearfix:after {
content: "";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.clearfix {
/*IE6、7专有*/
*zoom: 1;
}
.box {
width: 800px;
margin: 0 auto;
border: 1px solid blue;
}
.damao {
float: left;
width: 200px;
height: 300px;
background-color: rgb(221, 68, 68);
}
.ermao {
float: left;
width: 200px;
height: 200px;
background-color: rgb(46, 179, 172);
}
.footer {
width: 800px;
height: 200px;
background-color: rgb(196, 53, 224);
}
.clear {
clear: both;
}
</style>
</head>
<body>
<div class="box clearfix">
<div class="damao">大毛</div>
<div class="ermao">二毛</div>
<!-- <div class="clear"></div> -->
</div>
<div class="footer"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.clearfix:before,
.clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
/*IE6、7专有*/
*zoom: 1;
}
.box {
width: 800px;
margin: 0 auto;
border: 1px solid blue;
}
.damao {
float: left;
width: 200px;
height: 300px;
background-color: rgb(221, 68, 68);
}
.ermao {
float: left;
width: 200px;
height: 200px;
background-color: rgb(46, 179, 172);
}
.footer {
width: 800px;
height: 200px;
background-color: rgb(196, 53, 224);
}
.clear {
clear: both;
}
</style>
</head>
<body>
<div class="box clearfix">
<div class="damao">大毛</div>
<div class="ermao">二毛</div>
<!-- <div class="clear"></div> -->
</div>
<div class="footer"></div>
</body>
</html>