CSS - 允许 div 伸出其父级 [英] CSS - Allow an div to stick out of its parent
本文介绍了CSS - 允许 div 伸出其父级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在寻找一种允许 div 突出其父级的方法.
父元素有 float:right,我试图点击它来切换显示/隐藏子元素,但子元素在 div 之后显示/隐藏.我想让它突出"父 div.
谢谢!:)
解决方案
你的解释不是很清楚,但是这里有一个右对齐的父 div 和一个突出的子 div 的演示.我希望这就是你要找的 :)
#parent {宽度:200px;高度:200px;背景颜色:#FF0000;浮动:对;位置:相对;}#孩子 {宽度:300px;高度:100px;背景色:#00FF00;位置:绝对;右:0;}
家长<div id="孩子">孩子
I've been searching a lot for a way to allow a div to stick out of its parent.
The parent has float:right and I'm trying to make clicking it toggle show/hide a child element, but the child element shows/hides after the div. I'd like to make it "stick out" of the parent div.
Thanks! :)
解决方案
Your explanation is not very clear, but here is a demo of a right-aligned parent div with a child div that sticks out. I hope that is what you're looking for :)
#parent {
width: 200px;
height: 200px;
background-color: #FF0000;
float: right;
position: relative;
}
#child {
width: 300px;
height: 100px;
background-color: #00FF00;
position: absolute;
right: 0;
}
<div id="parent">
Parent
<div id="child">
Child
</div>
</div>
这篇关于CSS - 允许 div 伸出其父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文