我有一些类似于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;
}

最佳答案

真是巧合我只是在寻找一种使用滚动条将元素扩展到其他元素之外的方法,而您偶然发现了它。

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

关于html - 带有Z-index的google +圈子CSS溢出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11744578/

10-12 15:11