Removing margin on inline-block element after wrapping lines

后端 未结 7 1055
无人及你
无人及你 2021-01-01 22:33

I\'m hoping there\'s a way to do this without JavaScript. I have two elements displayed with inline-block. They are both 200 pixels in width and height, so they both appear

相关标签:
7条回答
  • 2021-01-01 23:25

    Just keep the inline container in a inline div and float them...

    Code:-

    <div id="wrapper" style="text-align: center;">
        <div id="outer" style="display: inline-block;">
        <div id="elem1" style="float:left; background-color: #f00; width: 200px; height: 200px;"></div>
        <div id="elem2" style="float:left; background-color: #00f; width: 200px; height: 200px; margin-left: 50px;"></div>
        </div>
    </div>
    

    Demo:- http://jsfiddle.net/YRshx/2/

    Thanks...

    0 讨论(0)
提交回复
热议问题