[英]css make element under the parent
i have the html like this : 我有这样的html:
<div class="a">
<div class="b/>
</div>
and it shows like 它显示像
---------
| div |
| |
|[ b ]|
---------
now, i want to make it to 现在,我想做到
---------
| div |
| |
| |
---------
[ b ]
b is a list which from db , I cannot know the width so I cannot use something like "bottom: -100px". b是一个来自db的列表,我不知道宽度,因此无法使用“ bottom:-100px”之类的东西。
.a { position: relative; width: 100px; height: 100px; background: pink; } .a:hover>.b { display: block; position: absolute; bottom: 0; width: 100%; background: blue; } .b { display: none; }
<div class="a"> 123 <div class="b"> <ol> <li>123</li> </ol> </div> </div>
You can use transform: translate(0, 100%);
您可以使用transform: translate(0, 100%);
. 。
.a { position: relative; width: 100px; height: 100px; background: pink; } .a:hover>.b { display: block; position: absolute; bottom: 0; width: 100%; background: blue; transform: translate(0, 100%); } .b { display: none; }
<div class="a"> 123 <div class="b"> <ol> <li>123</li> </ol> </div> </div>
Give top: 100%;
top: 100%;
评分top: 100%;
in .a:hover > .b
class and remove bottom:0
property. 在.a:hover > .b
类中,并删除bottom:0
属性。
.a { position:relative; width:100px; height:100px; background : pink; } .a:hover > .b{ display:block; position:absolute; top: 100%; width:100%; background : blue; } .b { display:none; }
<div class="a"> 123 <div class="b"> <ol> <li>123</li> </ol> </div> </div>
Use top: 100%;
使用top: 100%;
instead: 代替:
.a:hover>.b {
display: block;
position: absolute;
top: 100%;
width: 100%;
background: blue;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.