css搞砸了(自动高度)

时间:2015-12-16 19:07:49

标签: html css

我遇到了css样式的问题。当我将高度设置为自动website

时会发生这种情况

通过diung访问实时视图,请访问newproject.comli.com/post.php,使用用户名=发光密码= asdfgh123登录,然后手动转到newproject.comli.com/details.php

所以我的div高度设置为0不知道为什么。我在谈论#itemsCategListsform有人可以帮助我吗?这是我的代码:

 <div id="itemsCategListsform">
     <div id="plink">
        <div id="open">My details</div>
        <div id="closed"><a href="ads.php">My ads</a></div>
        <div id="closed"><a href="fav.php">Favorites</a></div>
     </div>
     <div id="pbase">
        <div id="detailforms">
            <p> Email:
              <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
                 <input type="email" name="email" size="30">
                 <input class="submit-buttonform" type="submit" name="updateemail" value="Update Email">
              </form>
            </p>
            <p>
              <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
                   Password: <br>
                   <input type="password" name="password" size="30"><br>
                    Re-Password: <br>
                   <input type="password" name="repassword" size="30">
                   <input class="submit-buttonform" type="submit" name="updatepassword" value="Update password" >
                </form>
                </p>
                Phone: 
                <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
                   <input type="text" name="phone" size="30">
                   <input class="submit-buttonform" type="submit" name="updatephone" value="Update phone">
                </form>
                Website:
                <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
                   <input type="text" name="website" size="30">
                   <input class="submit-buttonform" type="submit" name="updatewebsite" value="Update website">
                </form>
            </div>
        </div>
    </div>

和css:

#itemsCategListsform {
    background-color: white;
    position: relative;
    width: 930px;
    height: auto;
    left: 175px;
    top: 20px;
    border-radius: 4px;
    border: 1px solid #1a171a;
    padding-top: 40px;
    padding-left: 70px;
    -webkit-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
    -moz-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
    box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.6);
}

#plink {
    position: relative;
    width: 200px;
    float: left;
    border-top: 1px solid black;
    border-left: 1px solid black;
    z-index: 10;
    border-radius: 4px 0 0 4px;
    -webkit-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
    -moz-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
    box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);

}
#open {
    border-bottom: 1px solid black;
    border-right: 1px solid #fbfbfe;
    text-align: center;
    line-height: 50px;
    background-color: #fbfbfe;
}
#closed {
    border-bottom: 1px solid black;
    width: 200px;
    text-align: center;
    line-height: 50px;
}
#pbase {
    border: 1px solid black;
    background-color: #fbfbfe;
    position: relative;
    width: 600px;
    height: auto;
    float: left;
    margin-left: -1px;
    border-radius: 0px 4px 4px 4px;
    -webkit-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
    -moz-box-shadow: -3px 3px 5px -3px rgba(0,0,0,0.6);
    box-shadow: 3px 3px 5px -3px rgba(0,0,0,0.6);
}

#closed:hover a {
    display: block;
    background-color: #fbfbfe;
    border-right: 1px solid black;
}


#open:hover a {
    display: block;
}

#detailforms {
    position: relative;
    margin:0 auto;
    top: 10px;
    width: 450px;
    height: auto;
    margin-bottom: 40px;
}

3 个答案:

答案 0 :(得分:0)

display: inline-block添加到itemsCategListsform的css:)

答案 1 :(得分:0)

高度注册为0,因为子元素已浮动。 CSS float从内容流中获取一个元素,并在其周围包含内联元素。

你的问题在这里:

<div id="itemsCategListsform">
    <div id="plink">
    ...

#plink{ float: left; }
#phase{ float: left; }

我建议在父clear: both设置后添加一个伪元素。

<div id="itemsCategListsform" class="clearfix">
    <div id="plink">
    ...

.clearfix:after { 
    content: " ";
    display: block; 
    height: 0; 
    clear: both;
}

See some additional solutions here.

答案 2 :(得分:0)

好的,在DACrosby的帮助下很容易解决,因为他说因为浮动离开并解决了我只是添加溢出:auto;告诉我,如果我做得好或有更好的解决方案,因为这真的很容易,似乎没关系