<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="12.23课程源码/1223/static/font/iconfont.css">
<style>
*{
font-size:20px;
/*outline:1px dashed palevioletred;*/
}
.index-header{
width:1500px;
height:1000px;
margin:50px auto;
}
.index-header>.top{
height:70px;
position:relative;
}
.index-header>.top*{
height:inherit;
line-height:100px;
}
.index-header>.top>.logo{
width:250px;
position:absolute;
top:0;
left:0;
}
.index-header>.top>.search{
width:300px;
position:absolute;
right:450px;
top:15px
}
.index-header>.top>.quick{
width:400px;
position:absolute;
right:0;
top:30px;
}
.index-header>.top>.search>input[type="search"]{
width:300px;
height:33px;
border-radius:8px;
}
.index-header>.top>.search>input[type="search"]+label{
font-size:30px;
margin:-30px;
position: relative;
top:5px;
right:10px
}
.index-header>.nav {
height: 50px;
}
.index-header>.nav >.nav-item{
width:350px;
height:80px;
position:relative;
float:left;
}
.index-header>.nav >.nav-item >.iconfont{
font-size:50px;
color:rebeccapurple;
position:absolute;
}
.index-header>.nav .nav-item .tag{
width: 50px;
position:absolute;
left:65px;
border-right:1px solid palevioletred;
}
.index-header>.nav .nav-item .links{
width:300px;
position:absolute;
left:120px;
}
.index-header>.nav >.nav-item>.links>a:hover{
color:lightgreen;
}
.index-header>.slider-ads{
height:500px;
position:relative;
}
.index-header>.slider-ads>.slider{
width:900px;
position:absolute;
top:100px;
}
.index-header>.slider-ads>.ads{
width:200px;
position:absolute;
top:100px;
right:200px;
}
</style>
</head>
<body>
<div class="index-header">
<div class="top">
<div class="logo">
<a href="https://www.php.cn"><img src="12.23课程源码/1223/static/images/logo.png"></a>
</div>
<div class="search">
<input type="search" id="search"><label for="search" class="iconfont icon-icon_group"></label>
</div>
<div class="quick">
<span class="iconfont icon-icon_group"></span>
<span class="iconfont icon-icon_group"></span>
<span class="iconfont icon-icon_group"></span>
<span class="iconfont icon-icon_group"></span>
<span class="iconfont icon-icon_group"></span>
<span class="iconfont icon-icon_group"></span>
</div>
</div>
<div class="nav">
<div class="nav-item">
<span class="iconfont icon-DOC"></span>
<div class="tag">
<span>咨询</span>
<span>课程</span>
</div>
<div class="links">
<a href="">语文</a>
<a href="">数学</a>
<a href="">英语</a>
<a href="">政治</a>
<a href="">历史</a>
<br>
<a href="">生物</a>
<a href="">汉语</a>
<a href="">地理</a>
<a href="">美语</a>
<a href="">法语</a>
</div>
</div>
<div class="nav-item">
<span class="iconfont icon-DOC"></span>
<div class="tag">
<span>咨询</span>
<span>课程</span>
</div>
<div class="links">
<a href="">语文</a>
<a href="">数学</a>
<a href="">英语</a>
<a href="">政治</a>
<a href="">历史</a>
<br>
<a href="">生物</a>
<a href="">汉语</a>
<a href="">地理</a>
<a href="">美语</a>
<a href="">法语</a>
</div>
</div>
<div class="nav-item">
<span class="iconfont icon-DOC"></span>
<div class="tag">
<span>咨询</span>
<span>课程</span>
</div>
<div class="links">
<a href="">语文</a>
<a href="">数学</a>
<a href="">英语</a>
<a href="">政治</a>
<a href="">历史</a>
<br>
<a href="">生物</a>
<a href="">汉语</a>
<a href="">地理</a>
<a href="">美语</a>
<a href="">法语</a>
</div>
</div>
<div class="nav-item">
<span class="iconfont icon-DOC"></span>
<div class="tag">
<span>咨询</span>
<span>课程</span>
</div>
<div class="links">
<a href="">语文</a>
<a href="">数学</a>
<a href="">英语</a>
<a href="">政治</a>
<a href="">历史</a>
<br>
<a href="">生物</a>
<a href="">汉语</a>
<a href="">地理</a>
<a href="">美语</a>
<a href="">法语</a>
</div>
</div>
</div>
<div class="slider-ads">
<div class="slider">
<a href=""><img src="12.26/images/1.jpg" alt=""></a>
</div>
<div class="ads">
<a href=""><img src="12.26/images/banner-right.jpg" alt=""></a>
</div>
</div>
</div>
</div>
</body>
</html>
感觉有点乱#关于定位父级
意思是在这个.index-header>.slider-ads
盒子中把css代码写成 `position:relative;就是把slider-ads这个盒子定位为父级了吗
下面两个子元素写上position:absolute后,子元素位置的移动是相对于刚才定位的父元素做出改变
.index-header>.slider-ads{
height:500px;
position:relative;
}
.index-header>.slider-ads>.slider{
width:900px;
position:absolute;
top:100px;
}
.index-header>.slider-ads>.ads{
width:200px;
position:absolute;
top:100px;
right:200px;
}