【发布时间】:2019-02-20 16:07:10
【问题描述】:
我无法弄清楚如何将位于.content-wrapper{ overflow:hidden; .content{position:absolute;} } 下的元素移动到最顶部。
带有男人照片的图像元素放置在.content 元素下。但是由于父 .content-wrapper 具有 overflow:hidden 属性,他在照片上以黄色突出显示的头部部分(用红色箭头指向)被隐藏了。主要问题是我无法将隐藏的溢出更改为其他任何内容。
在不使用 JavaScript 的情况下解决这样的问题真的是这样吗?
==== 补充1 ====
为了澄清问题,我在下面编了一个代码sn-p:
.wrapper{
width:100%;
overflow:hidden;
position:initial;
padding:0 10px;
background-color:#EEEEEE;
box-sizing:border-box;
}
.content-wrapper{
position:relative;
overflow:hidden;
background-color:#DDDDDD;
margin:10px 0;
min-height:350px;
}
.content{
background-color:white;
position:absolute;
top:30px;
left:10px;
right:10px;
bottom:10px;
}
.content.grayed{
background-color:#CCCCCC;
}
.content.positioned{
top:50px;
left:180px;
bottom:-50px; //negative positioned parts supposed to be hidden
right:-50px; //as .content-wrapper has overflow:hidden;
}
.content.positioned img{
width:40%;
height:auto;
margin-top:-40vh; //but that is not supposed to be hidden out of .content-wrapper
margin-left:10vw;
min-width:250px;
}
<div class="wrapper">
.wrapper
<div class="content-wrapper">
.content-wrapper
<div class="content grayed" style="transform: rotate(-35deg); padding:20px;">
<strong>.content</strong> with cut off edges - that is supposed behaviour
</div>
</div>
<div class="content-wrapper">
.content-wrapper
<div class="content positioned">
<strong>.content</strong>
<img src="//i.imgur.com/DsOdy1V.png">
<br>
...and a man above is with sliced head - that is UNsupposed behaviour
</div>
</div>
</div>
真的没有办法吗?
【问题讨论】:
-
只要你使用溢出隐藏,没有脚本可以克服这个问题,如果照片当然是一个孩子,所以如果你发布一个最小的工作代码 sn-p 重现这个问题,我们很可能可以帮你摆脱
overflow: hidden -
@LGSon ,我添加了一个带有小示例的代码 sn-p。请你复习一下好吗?
-
@impulsgraw 你有没有把这个排序?这让我心碎????卡了三天,也许不可能
-
@peterflanagan 哦,我现在才注意到问题太老了 :) 可能 OP 将不再需要这个...
标签: html css overflow css-position z-index