google + circle css溢出z-index

时间:2012-07-31 16:15:51

标签: html css css3

我有一些像圈子一样的Google+,我似乎无法让overflow财产与他们合作。我认为它与圈子的z-index属性有关,虽然我已经尝试设置div的z-index以覆盖它而没有运气。

jsFiddle

HTML:

<div class="container">
   <div class="circle">
      <div class="outer-circle"></div>
      <div class="middle-circle"></div>
      <div class="inner-circle">4</div>
   </div>
   <div class="circle">
      <div class="outer-circle"></div>
      <div class="middle-circle"></div>
      <div class="inner-circle">3</div>
   </div>
   <div class="circle">
      <div class="outer-circle"></div>
      <div class="middle-circle"></div>
      <div class="inner-circle">2</div>
   </div>
   <div class="circle">
      <div class="outer-circle"></div>
      <div class="middle-circle"></div>
      <div class="inner-circle">1</div>
   </div>
</div>​

CSS:

div.container {
    height: 125px;
    width: 400px;
    overflow: scroll;
    border: 1px solid black;
}
div.circle {
    margin-left: 10px;
    margin-right: 10px;
    width: 130px;
    height: 130px;
    float: left;
}
div.circle:hover {
    cursor: pointer;
}
div.outer-circle {
    background: transparent;
    width: 122px;
    height: 122px;
    -webkit-border-radius: 61px;
    -moz-border-radius: 61px;
    border-radius: 61px;
    border: 1px solid #aaaaaa;
    position: absolute;
    z-index: 800;
    -webkit-transition: all .2s ease-in-out;
    -moz-transition: all .2s ease-in-out;
    -o-transition: all .2s ease-in-out;
    transition: all .2s ease-in-out;
}
div.outer-circle.hover {
    -moz-transform: scale(1.45);
    -webkit-transform: scale(1.45);
    transform: scale(1.45);
}
div.middle-circle {
    margin: 1px;
    width: 122px;
    height: 122px;
    -webkit-border-radius: 61px;
    -moz-border-radius: 61px;
    border-radius: 61px;
    background: #ececec;
    background: -moz-linear-gradient(top, #ececec 0%, #d8d8d8 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ececec), color-stop(100%,#d8d8d8)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #ececec 0%,#d8d8d8 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #ececec 0%,#d8d8d8 100%); /* Opera11.10+ */
    background: -ms-linear-gradient(top, #ececec 0%,#d8d8d8 100%); /* IE10+ */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ececec', endColorstr='#d8d8d8',GradientType=0 ); /* IE6-9 */
    background: linear-gradient(top, #ececec 0%,#d8d8d8 100%); /* W3C */
    position: absolute;
    z-index: 900;
    -webkit-transition: all .2s ease-in-out;
    -moz-transition: all .2s ease-in-out;
    -o-transition: all .2s ease-in-out;
    transition: all .2s ease-in-out;
}
div.middle-circle.hover {
    -moz-transform: scale(1.4);
    -webkit-transform: scale(1.4);
    transform: scale(1.4);
}
div.inner-circle {
    margin: 14px;
    background: #3C4049;
    width: 96px;
    height: 96px;
    font-size: 11px;
    color: #FFF;
    line-height: 96px;
    text-align: center;
    font-family: Arial;
    -webkit-border-radius: 48px;
    -moz-border-radius: 48px;
    border-radius: 48px;
    -webkit-box-shadow: inset 0px 1px 1px 0px #575757;
    -moz-box-shadow: inset 0px 1px 1px 0px #575757;
    box-shadow: inset 0px 1px 1px 0px #575757;
    border-bottom: 1px solid #FFF;
    position: absolute;
    z-index: 1000;
}

3 个答案:

答案 0 :(得分:1)

试试这个:

div.container {
    height: 125px;
    width: 400px;
    overflow: auto;
    border: 1px solid black;
    position: relative;
}
div.circle {
    margin-left: 10px;
    margin-right: 10px;
    width: 130px;
    height: 130px;
    float: left;
    position: relative;
}

现场演示:jsFiddle

答案 1 :(得分:0)

style="overflow:visible"?如果那不是您所要求的,请更具体地说明您想要发生的事情。

答案 2 :(得分:0)

多么巧合。我只是想找到一种方法,用滚动条扩展其他元素之外的元素,你偶然发现它。

要解决此问题,只需将position: relative;添加到div.container