CSS Positioning 70-30 with Inline-Block

前端 未结 4 1402
时光说笑
时光说笑 2021-01-15 13:07

I am positioning main-bar and side-bar with 70-30 ratio as under: JSFIDDLE

4条回答
  •  时光说笑
    2021-01-15 13:11

    You have to remove white space between divs as it also take place and doesn't let inline-blocks align properly.

    .main-bar, .side-bar {
        position: relative;
        margin: 0;
        padding: 0;
        outline: 0;
        display: inline-block;
        border: none;
        background: #CCC;
    }
    .main-bar {
        width: 70%;
    }
    .side-bar {
        width: 30%;
    }
    I am the King!

    Reference: Fighting the Space Between Inline Block Elements

提交回复
热议问题