老师,为什么我的a1下menu菜单栏那个橙色盒子显示不出来呢。
来源:2-7 使用CSS制作菜单
Vigorous阿炎
2020-10-23 17:20:17
css.css
.header-top{
height: 150px;
background-color: rgb(228, 187, 187);
}
.A{
height: 32px;
background-color: #2A2A2A ;
line-height: 32px;
}
.header-top .A .center-wrap{
}
.header-top .A .center-wrap .right .iconfont{
float: right;
margin-right: 16px;
line-height: 32px;
}
.header-top .A .center-wrap .right .iconfont:first-child{
margin-right: 0;
}
.header-top .A .center-wrap .right .dr,.zc{
font-size: 12px;
color: #FFFFFF;
text-align: justify;
line-height: 32px;
}
.header-top .A .center-wrap .A1{
float: left;
}
.header-top .A .center-wrap .A1> ul> li{
/* 大于号表示父亲的第一任儿子 */
font-size: 14px;
float: left;
margin-right: 18px;
}
.header-top a{
font-family: PingFangSC-Regular;
color: #FFFFFF;
text-align: justify;
line-height: 18px;
}
.header-top .A .center-wrap .A1> ul> li.a1{
/* li里面本身的一个a1元素用交集 */
padding-right:12px;
position: relative;
}
header-top .A .center-wrap .A1>ul>li.a1 .menu{
/* 为什么我的盒子没显示出来,难道是溢出隐藏掉了 */
position: absolute;
bottom: 30px;
right: 0;
width: 300px;
height: 400px;
background-color: rgb(138, 230, 102);
z-index: 9999;
}
.header-top .A .center-wrap .A1> ul> li.a1 .B{
position: absolute;
right: 0;
top: 50%;
margin-top: -6px;
width: 12px;
height: 12px;
transition: transform 0.2s linear 0s;
}
.header-top .A .center-wrap .A1> ul> li.a1:hover .B{
transform:rotate(180deg)
}
/* 先两个盒子使用绝对定位然后微调,然后大盒子hover,
之后控制大盒子transition旋转速度 */
.header-top .A .center-wrap .A1> ul> li.a1 .B .aa1{
position: absolute;
left: 2px;
top: 4px;
width: 6px;
height: 6px;
background-color: rgb(248, 248, 246);
transform: rotate(45deg);
}
.header-top .A .center-wrap .A1> ul> li.a1 .B .aa2{
position: absolute;
top: 2px;
left: 2px;
width: 6px;
height: 6px;
background-color: #2A2A2A;
transform: rotate(45deg);
}
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>慕云游</title>
<meta name="keywords" content="旅游,机票,观光,休闲">
<meta name="Description" content="旅游好地方,给你身心放个假,
机票,度假,观光,休闲旅游必去的地方">
<link rel="stylesheet" href="CSS/reset.css">
<link rel="stylesheet" href="CSS/base.css">
<link rel="stylesheet" href="CSS/css.css">
</head>
<body>
<head>
<header class="header-top site-head">
<!-- 整个页面区域 -->
<div class="A topbar">
<!-- 中间上半部分区域,还有下半部分所以需要分区 -->
<div class="center-wrap">
<!-- 正式编辑区 -->
<div class="A1">
<ul>
<li>
<a href="">目的地</a>
</li>
<li>
<a href="">锦囊</a>
</li>
<li class="a1">
<a href="">社区</a>
<div class="B">
<em class="aa1"></em>
<em class="aa2"></em>
</div>
</li>
<li>
<a href="">行程助手</a>
</li>
<li class="a1">
<a href="">商城</a>
<div class="B">
<em class="aa1"></em>
<em class="aa2"></em>
</div>
</li>
<li class="a1">
<a href="">酒店民宿</a>
<div class="B">
<em class="aa1"></em>
<em class="aa2"></em>
</div>
<div class="menu"></div>
</li>
<li>
<a href="">特价酒店</a>
</li>
</ul>
</div>
<div class="right">
<a class="iconfont dr" href="">登入</a>
<a class="iconfont zc" href="">注册</a>
<a class="iconfont" href=""></a>
<a class="iconfont" href=""></a>
<a class="iconfont" href=""></a>
<span class="iconfont">|</span>
<a class="iconfont" href=""></a>
</div>
</div>
</div>
在这里输入代码,可通过选择【代码语言】突出显示
3回答
同学你好,是指把下方代码修改为bottom和right吗?
如果是的话,那么解答如下:
类名为a1的元素设置了定位,类名为menu的元素是相对于a1定位的,如果menu的bottom属性设置为0,menu的底部会在a1的底部显示,因为a1已经在页面的最上方了,menu的高度比a1的大,所以menu会被覆盖一部分。
建议:可以把bottom值设置为负值,也可以把right和bottom值替换为left和top值,祝学习愉快~
Vigorous阿炎
提问者
2020-10-23
可是当我设置right 和bottom值时,发现橙色盒子不是在右下角出现的。位置出现的不对。
好帮手慕言
2020-10-23
同学你好,相似的问题,在同学的另一个提问中解答了,快去查看吧,链接:http://class.imooc.com/course/qadetail/261217,祝学习愉快~
相似问题