Overlapping inline div

我的梦境 提交于 2019-12-11 02:09:18

问题


I have this problem and I'm trying to solve it using jsfiddle but I'm not good in css. Hoping that you can help me solve this. I wanted to separate the next div on the second line. Just a little space to avoid the overlapping. I need it to display inline but the problem is if it goes to the next line, the next line of divs overlaps the previous line of divs. How can I add a margin from it knowing that I'm setting all the divs to display inline?

Thanks in advance :)


回答1:


Is this acceptable?

http://jsfiddle.net/2bLs7/11/

.a{
    border:solid 1px black;
    display:inline-block;
    margin-bottom: 1px;

    zoom: 1;
    *display: inline
}

Changing to inline-block might not be what you're after, but if you don't mind doing that, this seems good.

I included the hacks necessary to make this work in IE7.




回答2:


You can add line-height: 150% to it to add a gap.




回答3:


Try this:

.a {
  border: solid 1px black;
  display: inline-block;
  margin: 5px 0 0 0;
}

See there, I use inline-block oppose to inline. margin: 5px 0 0 0; tells it to have 5px of margin on top.



来源:https://stackoverflow.com/questions/5162957/overlapping-inline-div

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!