前端18、19天–景深、背面不可见、正方体、浮动布局、列表布局、双飞翼布局、固比固、圣杯、flex布局项目
景深
<style>
.container {
/* transform-style: preserve-3d; */
perspective: 1000px;
/* transform: rotateY(30deg); */
width: 300px;
height: 120px;
border: 5px solid black;
}
/* 垂直屏幕方向,向用户移动300px */
img {
width: 300px;
height: 120px;
/* transform: translateZ(300px); */
}
.img1 {
/* transform: translateZ(100px); */
transform: rotateY(50deg);
}
.img2 {
/* transform: translateZ(-100px); */
transition: all 1s;
}
.img2:hover {
transform:rotateX(180deg);
}
</style>
</head>
<body>
<div class="container">
<img class="img1" src="../../pic/3.png" alt="">
<img class="img2" src="../../pic/4.png" alt="">
</div>
</body>
背面不可见
图片翻转,背面不可见
.img2:hover {
transform: rotateX(180deg);
}
.img1 {
transform: rotateX(180deg);
transition: all 1s;
}
正方体
<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>
.container {
position: relative;
margin: 200px auto;
transform-style: preserve-3d;
/* perspective: 1000px; */
/* 给容器一个角度,就可以看到正放心各个面的位置 */
transform: rotate3d(1,1,0,-40deg);
}
.box {
width: 300px;
height: 300px;
font-size: 50px;
color: white;
margin: 0 auto;
position: absolute;
left: calc(50% - 300px/2);
border: 2px solid black;
}
.box1 {
background-color: pink;
transform:translateZ(150px);
}
.box2 {
background-color: red;
transform: translateX(-150px) rotate3d(0,1,0,-90deg);
/* 后面的transform会将前面的覆盖掉,所以旋转和位移要写在同一行 */
/* transform: rotate3d(0,1,0,90deg); */
}
.box3 {
background-color: skyblue;
transform: translateY(150px) rotate3d(1,0,0,-90deg);
}
.box4 {
background-color: black;
transform: translateX(150px) rotate3d(0,1,0,90deg);
}
.box5 {
background-color: burlywood;
transform: translateY(-150px) rotate3d(1,0,0,90deg);
}
.box6 {
background-color: chocolate;
transform:translateZ(-150px) rotate3d(1,0,0,180deg)
}
</style>
</head>
<body>
<div class="container">
<div class="box box1">1</div>
<div class="box box2">2</div>
<div class="box box3">3</div>
<div class="box box4">4</div>
<div class="box box5">5</div>
<div class="box box6">6</div>
</div>
</body>
浮动布局
<style>
.top {
height: 50px;
background-color: red;
}
/* .content {
height: 600px;
background-color: yellow;
} */
.container {
width: 70%;
height: 700px;
margin: 0 auto;
background-color: yellow;
overflow: hidden;
}
.info {
height: 100%;
width: 40%;
background-color: skyblue;
float: left;
}
.slider {
height: 100%;
width: 60%;
background-color: gold;
float: left;
}
.fl {
height: 70%;
width: 95%;
background-color: green;
float: right;
}
.footer {
height: 50px;
background-color: pink;
}
</style>
</head>
<body>
<div class="top"></div>
<div class="content">
<div class="container">
<div class="info"></div>
<div class="slider">
<div class="fl"></div>
</div>
</div>
</div>
<div class="footer"></div>
</body>
列表布局
<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: 0px;
padding: 0px;
list-style: none;
}
.u{
/* 想要li前面没有缩进,就要清除padding的默认值 */
width: 800px;
height: 1000px;
overflow: hidden;
background-color: pink;
border: 1px solid black;
}
.l {
width: 150px;
height: 150px;
background-color: green;
font-size: 50px;
color: white;
text-align: center;
line-height: 150px;
float: left;
margin: 10px 10px 10px 0px;
}
</style>
</head>
<body>
<div class="container">
<ul class="u">
<li class="l l1">1</li>
<li class="l l2">2</li>
<li class="l l3">3</li>
<li class="l l4">4</li>
<li class="l l5">5</li>
<li class="l l6">6</li>
<li class="l l7">7</li>
<li class="l l8">8</li>
<li class="l l9">9</li>
<li class="l l10">10</li>
<li class="l l11">11</li>
<li class="l l12">12</li>
<li class="l l13">13</li>
<li class="l l14">14</li>
<li class="l l15">15</li>
<li class="l l16">16</li>
<li class="l l17">17</li>
<li class="l l18">18</li>
<li class="l l19">19</li>
<li class="l l20">20</li>
</ul>
</div>
</body>
双飞翼布局
双飞翼center有个父元素是浮动的
固比固比较快
<style>
.container {
width: 60%;
height: 500px;
float: left;
margin-left: 20%;
}
.center {
height: 500px;
margin: 0px 200px;
background-color: skyblue;
}
.left {
float: left;
width: 200px;
height: 500px;
margin-left: -60%;
background-color: pink;
}
.right {
float: left;
width: 200px;
height: 500px;
margin-left: -200px;
background-color: yellowgreen;
}
</style>
</head>
<body>
<div class="container">
<div class="center"></div>
</div>
<div class="left"></div>
<div class="right"></div>
</body>
固比固
<style>
.left {
width: 200px;
height: 500px;
background-color: skyblue;
float: left;
}
.right {
width: 300px;
height: 500px;
background-color: slateblue;
float: right;
}
.center {
height: 500px;
margin: 0px 310px 0px 210px;
background-color: tan;
}
</style>
</head>
<body>
<div class="left"></div>
<div class="right"></div>
<div class="center"></div>
</body>
圣杯布局
<style>
.main {
width: 80%;
margin:0 auto;
background-color: skyblue;
overflow: hidden;
}
.box {
padding-bottom: 300px;
margin-bottom: -300px;
}
.left {
float: left;
width: 200px;
height: 500px;
background-color: yellow;
}
.right {
float: right;
width: 300px;
height: 600px;
background-color: yellowgreen;
}
.center {
height: 800px;
margin-left: 210px;
margin-right: 310px;
background-color: pink;
}
</style>
</head>
<body>
<div class="main">
<div class="box left"></div>
<div class="box right"></div>
<div class="box center"></div>
</div>
</body>
圣杯布局
flex布局
flex布局项目
示意图
<style>
* {
padding: 0;
margin: 0;
list-style: none;
}
.status {
height: 30px;
background-image: -webkit-linear-gradient(top,blue,skyblue);
}
.container1 {
width: 80%;
margin: 0 auto;
display: flex;
justify-content: flex-end;
font-size: 18px;
color: white;
}
.demo1 {
margin-right: 20px;
}
.demo11 {
margin-right: 70px;
}
.space {
white-space: pre;
}
.paint {
width: 20px;
height: 20px;
position: relative;
}
.paint::before {
content: "";
width: 10px;
height: 10px;
border: 1px solid white;
border-radius: 5px;
position: absolute;
top: 3px;
left: 3px;
}
.paint::after {
content: "";
width: 14px;
height: 7px;
/* background-color: pink; */
border: 1px solid white;
border-radius: 7px 7px 0 0;
position: absolute;
top: 15px;
left: 1px;
}
/* 导航栏 */
.nav {
width: 100%;
background-color: white;
box-shadow: 0px 2px 20px grey;
}
.container2 {
width: 70%;
margin: 0 auto;
display: flex;
justify-content: flex-start;
align-items: center;
}
.nav1 {
width: 50px;
margin-right: 200px;
font-size: 30px;
}
.nav2 {
display: flex;
justify-content: flex-start;
flex: 1;
}
.nav2 span {
margin-right: 50px;
}
.nav3 input {
height: 20px;
outline: none;
}
.nav3 {
position: relative;
}
.nav3 .search {
position: absolute;
/* margin:0px 20px; */
left: 50px;
top: 5px;
font-size: 8px;
}
.nav3 .search span {
background-color: #DDDDDD;
border-radius: 2px;
}
.nav3::before {
content: "";
width: 12px;
height: 12px;
border: 2px solid black;
border-radius: 7px;
position: absolute;
right: 10px;
top: 3px;
}
.nav3::after {
content: "";
border-top: 2px solid black;
font-size: 10px;
width: 8px;
height: 2px;
position: absolute;
transform: rotate(45deg);
right: 5px;
top: 18px;
}
.container3 {
position: relative;
width: 70%;
height:550px ;
margin: 0 auto;
background: url(../../pic/banner.jpg) center no-repeat;
}
.arrows {
font-size: 60px;
color: white;
margin-top: -30px;
position: absolute;
top: 50%;
width: 100px;
height: 100px;
background: rgba(102,51,51, 0.3);
/* left能覆盖right,所以要先设置right */
right: 30px;
}
.arrow1 {
left: 30px;
}
.gradient {
width: 70%;
margin: 0 auto;
height: 25px;
position: relative;
overflow: hidden;
}
.gradient::after {
content: "";
border: 25px solid transparent;
border-left-width: 0px;
border-right:1332px solid skyblue;
/* 伪元素消除默认字体大小 */
font-size: 0px;
position: absolute;
top: 0px;
}
.container4 {
width: 70%;
margin: 0 auto;
text-align: center;
}
.container4 select {
width: 160px;
height: 25px;
margin: 5px 20px;
}
.range {
height: 100px;
width: 70%;
margin: 0 auto;
}
.range input {
margin: 20px 25%;
width: 600px;
}
.info {
display: flex;
justify-content: center;
}
.image {
width: 40%;
}
.image img {
width: 100%;
height: 100%;
}
.xinghao {
width: 40%;
}
</style>
</head>
<body>
<!--状态栏 -->
<div class="status">
<div class="container1">
<span class="demo1">华为商城</span>
<span class="demo1">花粉俱乐部</span>
<span class="demo1 demo11">EMUI</span>
<span class="paint"></span>
<span>登录</span>
<span class="space"> | </span>
<span>注册</span>
</div>
</div>
<!-- 导航 -->
<div class="nav">
<div class="container2">
<div class="nav1">HONOR</div>
<div class="nav2">
<span>产品</span>
<span>关于荣耀</span>
<span>新闻评测</span>
<span>视频</span>
<span>活动</span>
<span>服务支持</span>
</div>
<div class="nav3">
<input type="text">
<div class="search">
<span>荣耀20S</span>
<span>荣耀9X</span>
</div>
</div>
</div>
</div>
<!-- banner 部分 -->
<div class="banner">
<div class="container3">
<div class="arrows arrow1"><span><</span></div>
<div class="arrows arrow2"><span>></span></div>
</div>
</div>
<br>
<!-- 手机模块介绍部分 -->
<div class="gradient">
</div>
<div class="range">
<input type="range">
</div>
<div class="intro">
<div class="container4">
<h2>找到适合你的手机</h2>
<select name="" id="">
<!-- 给select添加placeholder -->
<option value="" style="display: none;">产品类型</option>
<option value="">helloworld</option>
</select>
<select name="" id="">
<option value="" style="display: none;">屏幕尺寸</option>
<option value="">helloworld</option>
</select>
<select name="" id="">
<option value="" style="display: none;">网络格式</option>
<option value="">helloworld</option>
</select>
<select name="" id="">
<option value="" style="display: none;">发布时间</option>
<option value="">helloworld</option>
</select>
<div class="info">
<div class="image">
<img src="../../pic/xinghao.jpg" alt="">
</div>
<div class="xinghao">
<h2></h2>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
</div>
</div>
</div>
</div>
</body>