相对div中绝对div的左位置总数?

问题描述 投票:0回答:1

我有以下代码:

Fiddle

.item {
    width: 120px;
    padding: 10px;
    display: block;
    background-color: #CCC;
    float: left;
    margin: 5px;
    position: relative;
}

.item .item-preview {
    position: relative;
    z-index: 10;
    display: block;
}

.item .item-content {
    /*display: none;*/
   position: absolute;
   left: 0px;
   top: 37px;
   padding: 5%;
   z-index: 11;
   width: 90%;
   background-color: #000;
   color: #FFF;
}

我希望div“.item-content”,当它显示时,总是在左侧,并且与整个页面一样宽,我该怎么做?

css mootools
1个回答
1
投票

如果从position: relative中删除.item,您将获得所需的效果。我还删除了top: 37px;来修复垂直定位。如果你需要调整它,请改用margin-top

Fiddle

© www.soinside.com 2019 - 2024. All rights reserved.