margin-top not working with clear: both

后端 未结 8 2120
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 00:53

8条回答
  •  北海茫月
    2020-11-29 01:01

    Sometimes a combination of position relative and margin can solve these type of problems.

    I use this technique for my alignright and alignleft classes in WordPress.

    For instance if I want a "bottom margin" that is respected by clearing elements you can use.

    .alignright{
       float: right;
       margin-left: 20px;
       margin-top: 20px;
       position: relative;
       top: -20px;
    }
    

    For your example you could do something like

    Left
    Right
    Main Data

提交回复
热议问题