【问题标题】:Toggle div container overlapping another container under it切换 div 容器与它下面的另一个容器重叠
【发布时间】:2012-09-13 21:41:47
【问题描述】:

我网站的表单页面上有 3 个 div。每当我单击切换按钮时,左上角的切换与底部 div 重叠。

我想要做的是,当点击顶部 div 容器时,左下角的 div 容器应该向下移动,并在关闭切换时移回原来的位置。

我已经包含了正确 div 的 css,我不知道那是不是影响它旁边两个 div 位置的 css。

切换前

切换后

用于切换的 CSS

#toggle-view {
list-style:none;    
font-family:arial;
font-size:10px;
margin:0;
padding:0;
width:200px; 
position: absolute;
}

#toggle-view li {
    list-style:none;
    text-decoration:none;
    font-size:13px;
    font-family:'lato';
    padding:2px;
    margin:10px;
    margin-left:20px;
    position:relative;
    cursor:pointer; 
    border-radius: 5px;    
}

 #toggle-view li a:hover {
    color: brown;  
}

#toggle-view h3 {
    margin:0;
    font-size:13px;
    color:#2a5a9a;
}

#toggle-view span {
    position:absolute;
    right:5px; top:0;
    color:#2a5a9a;
    font-size:20px;
    font-weight: bolder;
}

#toggle-view p {
    margin:5px 0;
    display:none;
}

#toggle-view a{
    padding:5px 0;
    color:#35371c; 
}

#toggle-view a:hover{

     color:#2a5a9a;
}

LeftBox 的 CSS

.report{
position: absolute;
margin-top:100px;
margin-left:0;
padding-left: 20px;
}

右侧框的 CSS

.register-body {
height:auto;
font-size:1em;
width:710px;
position:relative;
color:#000;
border-radius:5px;
background-color:#d2d4bb;
line-height:20px;         
margin:20px 0 20px 250px;
padding:15px 15px 0; 
}

更新

当我改变时

#toggle-view {
position: absolute;
}

#toggle-view {
position: relative;
}

.report{
 position: absolute;
}

.report{
 position: relative;
 }

我知道了:

右框被推到左下框下方。

【问题讨论】:

    标签: css html position containers


    【解决方案1】:

    这是因为您使用的是绝对位置。尝试在没有绝对定位的情况下进行布局,然后它会根据你的全能意志移动、弯曲和弯曲! :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-26
      • 1970-01-01
      • 2012-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多