定位绝对时溢出,不起作用。

时间:2014-04-20 16:20:01

标签: html css

我有一个div定位相对而且在里面有另一个div定位绝对。 我已经给出了主要的div溢出:隐藏和边界无线电......然而,div内部的边缘没有覆盖在主要内部,即溢出不起作用。

实时预览和完整代码:http://jsfiddle.net/sYv78

<div class="gridElement">
    <img alt="image" src=
    "https://pbs.twimg.com/profile_images/441318694942031872/I2cc6yMB.jpeg">

    <div class="animate">
        <p>Short Description</p>
    </div><a href=""></a>
</div>

.frames img, .frame {
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
}
/*Grids System*/
 .grids {
    -webkit-column-count: 3;
    -moz-column-count: 3;
    column-count: 3;
    -webkit-column-gap: 10px;
    -moz-column-gap: 10px;
    column-gap: 10px;
}
.grids.columns2 {
    -webkit-column-count: 2;
    -moz-column-count: 2;
    column-count: 2;
}
.grids.columns4 {
    -webkit-column-count: 4;
    -moz-column-count: 4;
    column-count: 4;
}
.grids .gridElement {
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    -ms-backface-visibility: hidden;
}
.grids .gridElement:last-child {
    margin-bottom: 0;
}
.grids .gridElement img {
    min-width: 100%;
}
.grids .gridElement .animate {
    color: #fff;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    padding-top: 20%;
    text-align: center;
    filter: alpha(opacity=0);
    opacity: 0;
    -webkit-transition: all .4s linear;
    -moz-transition: all .4s linear;
    -o-transition: all .4s linear;
    transition: all .4s linear;
}
.grids .gridElement:hover > .animate {
    filter: alpha(opacity=1);
    opacity: 1;
}
.grids .gridElement .animate span.background {
    background-color: #3F8AE4;
    filter: alpha(opacity=70);
    opacity: 0.70;
}
.grids .gridElement .animate span {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    padding-top: 20%;
    font-size: 2em;
}
.grids .gridElement a {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}
.grids .gridElement a * {
    cursor: pointer;
}
.grids .gridElement .animate p {
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 0 15px 15px 0;
}

1 个答案:

答案 0 :(得分:0)

关于overflow: hidden;的奇怪之处在于它需要固定的边界才能工作。通过为.grids .gridElement类指定固定高度,例如500px,溢出仍然隐藏:)