01企业站新闻模块讲解
<!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;
}
a{
text-decoration: none;
}
.news{
width: 453px;
height: 241px;
background: orange;
padding-left: 1px;
padding-right: 28px;
overflow: hidden;
}
.news h2{
font-size: 18px;
color: #41454e;
font-weight: 500;
margin-top: 33px;
margin-bottom: 20px;
}
.news li{
font-size: 12px;
line-height: 25px;
}
.news li a{
color: #555555;
display: block;
/* height: ; */
overflow: hidden;
}
.span1{
float: left;
display: block;
width: 300px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.span2{
float: right;
}
</style>
</head>
<body>
<div class="news">
<h2>动态新闻</h2>
<ul>
<li>
<a href="#">
<span class="span1">我是左边的新闻</span>
<span class="span2">2022-07-13</span>
</a>
</li>
<li>
<a href="#">
<span class="span1">我是下方的内容我是下我是下方的内容我是下方的内容我是下方的内容方的内容我是下方的内容</span>
<span class="span2">2022-07-13</span>
</a>
</li>
<li>
<a href="#">
<span class="span1">我是左边的新闻内容,我是左边的新闻内容</span>
<span class="span2">2022-07-13</span>
</a>
</li>
<li>
<a href="#">
<span class="span1">我是左边的新闻内容,我是左边的新闻内容</span>
<span class="span2">2022-07-13</span>
</a>
</li>
<li>
<a href="#">
<span class="span1">我是左边的新闻内容,我是左边的新闻内容</span>
<span class="span2">2022-07-13</span>
</a>
</li>
<li>
<a href="#">
<span class="span1">我是左边的新闻内容,我是左边的新闻内容</span>
<span class="span2">2022-07-13</span>
</a>
</li>
</ul>
</div>
</body>
</html>
02定位学习
<!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>
</head>
<body>
<!--
定位 position
1.绝对定位 position:absolute;
2.相对定位 position:relative;
3.固定定位 position:fixed;
4.粘性定位 position:sticky;
5.默认值 position:static;
-->
</body>
</html>
03绝对定位学习
<!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;
}
.box1{
width: 200px;
height: 200px;
background: green;
}
.box2{
width: 250px;
height: 250px;
background: orange;
position: absolute;
right: 0;
top: 0;
}
.box3{
width: 300px;
height: 300px;
background: skyblue;
}
</style>
</head>
<body>
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">asdasdasasaas3</div>
<!--
(一)绝对定位 position:absolute;
定位一定有方位:上top 下bottom 左left 右right
特点:
1.给元素添加绝对定位之后,元素就飘了,不要自己的位置了,可以实现覆盖;
2.一定要给绝对定位元素添加方位;
3.方位的移动是有参照物:
3.1 默认情况下,围绕着浏览器的第一屏做位置移动;
3.2 围绕着父元素做位置移动,前提条件是,父元素身上一定需要有定位设置
绝对定位使用的口诀:谁要动就给谁添加绝对定位
-->
</body>
</html>
04绝对定位相对父元素做位置移动
<!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;
}
.boss{
width: 500px;
height: 500px;
background: orange;
/* position: absolute; */
/*相对定位 占位置*/
position: relative;
}
.box{
width: 200px;
height: 200px;
background: green;
position: absolute;
right: -10px;
bottom: 10px;/*正值都是向里面移动的,负值都是向外移动*/
}
.content{
width: 700px;
height: 700px;
background: pink;
}
</style>
</head>
<body>
<div class="boss">
<div class="box">我是小盒子</div>
</div>
<div class="content">我是西我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的我是西方的方的</div>
</body>
</html>
05相对定位的学习
<!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;
}
.box1{
width: 200px;
height: 200px;
background: green;
}
.box2{
width: 250px;
height: 250px;
background: orange;
position: relative;
left: 30px;
top: 20px;
}
.box3{
width: 300px;
height: 300px;
background: skyblue;
}
</style>
</head>
<body>
<!--
(二)相对定位 position:relative;
特点:
1.给元素添加相对定位之后,元素没有飘,占位置在;
2.也有参照物,围绕着自己原来的位置做移动;
一般是给绝对定位元素的父元素添加的
-->
<div class="box1">1</div>
<div class="box2">2</div>
<div class="box3">3</div>
</body>
</html>
06腾讯大学定位案例
<!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;
}
.box{
width: 228px;
height: 160px;
background: pink;
margin: 100px auto;
position: relative;
}
.box a{
display: block;
width: 228px;
height: 160px;
color: #fff;
}
.box img{
width: 228px;
height: 160px;
}
.sbox{
width: 228px;
height: 26px;
/* background: green; */
position: absolute;
left: 0;
bottom: 0;
font-size: 12px;
line-height: 26px;
}
.sbox span{
display: block;
width: 20px;
height: 26px;
background: #e02917;
text-align: center;
float: left;
}
.sbox p{
width: 198px;
height: 26px;
background: rgba(0,0,0,0.4);
float: left;
padding-left: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div class="box">
<a href="#">
<img src="img/img1.jpg" alt="">
<div class="sbox">
<span>1</span>
<p>我是右边的我是,右边的内容内容内容容</p>
</div>
</a>
</div>
</body>
</html>
06腾讯大学定位案例3
<!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;
}
.box{
width: 228px;
height: 160px;
background: pink;
margin: 100px auto;
position: relative;
}
.box a{
display: block;
width: 228px;
height: 160px;
color: #fff;
}
.box img{
width: 228px;
height: 160px;
}
.sbox{
width: 228px;
height: 26px;
/* background: green; */
position: absolute;
left: 0;
bottom: 0;
font-size: 12px;
line-height: 26px;
/* display: none; */
opacity: 0;
transition: 1s;
}
.box:hover .sbox{
/* display: block; */
opacity: 1;
/* transition: 2s; */
}
.sbox span{
display: block;
width: 20px;
height: 26px;
background: #e02917;
text-align: center;
float: left;
}
.sbox p{
width: 198px;
height: 26px;
background: rgba(0,0,0,0.4);
float: left;
padding-left: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div class="box">
<a href="#">
<img src="img/img1.jpg" alt="">
<div class="sbox">
<span>1</span>
<p>我是右边的我是,右边的内容内容内容容</p>
</div>
</a>
</div>
</body>
</html>
07透明颜色写法
<!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: 200px;
height: 200px;
background: rgba(255,0,0,0.5);
/*rgba() alpha 透明度 0-1 值越小就越透明*/
}
</style>
</head>
<body>
<div class="box">我是盒子</div>
</body>
</html>
08透明属性opacity
<!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;
}
.box{
width: 200px;
height: 200px;
background: red;
opacity: 0.5;
}
</style>
</head>
<body>
<div class="box">我是盒子</div>
<!--
透明属性 opacity:0-1; 值越小就越透明
opacity:0; 全透明,占位消失
opacity:1; 正常显示
可以结合transition做过渡动画效果
transition添加2种效果:
1.鼠标滑过有过渡动画,鼠标移开也有过渡动画,transition应该添加在元素本身;
2.鼠标滑过有过渡动画,鼠标移开没有过渡,transition应该添加在hover处。
-->
</body>
</html>
09过渡动画消失和出现
<!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;
}
.box{
width: 300px;
height: 200px;
margin: 50px auto;
position: relative;
}
.box img{
width: 300px;
height: 200px;
}
.shadow{
width: 300px;
height: 200px;
background: rgba(255,255,255,0.3);
position: absolute;
left: 0;
top: 0;
opacity: 0;
transition: 0.8s;
}
.box:hover .shadow{
opacity: 1;
}
</style>
</head>
<body>
<div class="box">
<img src="img/img1.jpg" alt="">
<div class="shadow"></div>
</div>
</body>
</html>
10一个小盒子在一个大盒子里面做水平垂直居中
<!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;
}
/*一、纯margin + overflow:hidden;*/
/* .boss{
width: 500px;
height: 500px;
background: orange;
overflow: hidden;
}
.box{
width: 200px;
height: 200px;
background: green;
margin-left: 150px;
margin-top: 150px;
} */
/*二、纯padding*/
/* .boss{
width: 350px;
height: 350px;
background: orange;
padding-top: 150px;
padding-left: 150px;
}
.box{
width: 200px;
height: 200px;
background: green;
} */
/*三、定位*/
/* .boss{
width: 500px;
height: 500px;
background: orange;
position: relative;
}
.box{
width: 200px;
height: 200px;
background: green;
position: absolute;
left: 150px;
top: 150px;
} */
/*四、display:inline-block; + line-height + vertical-align + text-align*/
/* .boss{
width: 500px;
height: 500px;
background: orange;
text-align: center;
line-height: 500px;
}
.box{
width: 200px;
height: 200px;
background: green;
display: inline-block;
vertical-align: middle;
} */
/*五、定位 + margin取负值 */
/* .boss{
width: 500px;
height: 500px;
background: orange;
position: relative;
} */
/* .box{
width: 200px;
height: 200px;
background: green;
position: absolute; */
/*向右移动父元素宽度的一半*/
/* left: 50%; */
/*向左移动自身宽度的一半*/
/* margin-left: -100px; */
/*向下移动父元素高度的一半*/
/* top: 50%; */
/*向上移动自身高度的一半*/
/* margin-top: -100px; */
/* } */
/*六、定位 + margin:auto;*/
.boss{
width: 500px;
height: 500px;
background: orange;
position: relative;
}
.box{
width: 200px;
height: 200px;
background: green;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
}
</style>
</head>
<body>
<!--
一个宽高为200*200的小盒子在一个宽高为500*500的大盒子里做水平垂直居中,请问你有哪些方法实现?(6种)
-->
<div class="boss">
<div class="box"></div>
</div>
</body>
</html>
11轮播图的按钮书写
<!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;
}
.big_div{
width: 100%;
height: 400px;
background: green;
position: relative;
}
.box{
width: 200px;
height: 30px;
background: rgba(0,0,0,0.5);
position: absolute;
left: 50%;
margin-left: -100px;
bottom: 10px;
}
</style>
</head>
<body>
<div class="big_div">
<div class="box"></div>
</div>
</body>
</html>