在div上填充左侧移动下一个div

时间:2014-10-29 19:15:04

标签: html css

我坚持这个小问题,非常愚蠢我知道,但我找不到配置-css来解决问题(位置相对margin-left,padding-left,没有一个工作)

问题:在此div中添加一个填充 - sidebar-user-div11

CSS

.sidebar-user{
    position: relative;
    width: 100%;
    background-color: #ff7801;
    background: #ff7801;
}

.sidebar-user-div1{
    /*position: relative;*/
    width: 100%;
    height: 40px;
    background-color: purple;
}
.sidebar-user-div2{
    /*position: relative;*/
    width: 100%;
    height: 30px;
    background-color: yellow;
}

.sidebar-user-div11{
    /*position: relative;*/
    float: left;
    width: 80%;
    height: 40px;
    line-height: 40px;
    /*margin-left: 15px;*/
    color: white;
    background-color: red;
    padding-left: 10px;
}
.sidebar-user-div12{
    /*position: relative;*/
    float: left;
    width: 20%;
    height: 40px;
    background-color: black;
}

HTML

<div class="sidebar-user">
    <div class="sidebar-user-div1">
        <div class="sidebar-user-div11">
            Text with padding left :(
        </div>
        <div class="sidebar-user-div12">

        </div>  
    </div>
    <div class="sidebar-user-div2">

    </div>
</div>

jsfiddle

1 个答案:

答案 0 :(得分:2)

尝试添加...

box-sizing:border-box; 

到div11(http://jsfiddle.net/pahy7x24/2/