保证金不起作用?两个元素之间需要空间 [英] Margin doesn't work? Need space between two elements

查看:109
本文介绍了保证金不起作用?两个元素之间需要空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我很抱歉,我不把我的链接放在这里,这是一个工作网站,我不允许。我会在必要的时候发布我的代码的相关部分。



所以这个问题很基本 - 我有一个div与一些图像和一个头< h3> ,在这里我的内容开始。无论我尝试在两者之间创造一些空间,它都不起作用。我在两个元素上尝试了margin和padding,在相对位置和绝对位置之间切换,并且抛出了大量< br> 标签。没什么用的!



是什么导致我的两个元素如此吸引对方?什么可能导致无法在两个元素之间创建空间?

谢谢!

编辑:这是我的css代码div:

  .bmwrapper {
width:720px;
职位:亲属;
margin-left:auto;
margin-right:auto;
z-index:1;
}

.bmvenstre {
float:left;
text-align:left;
z-index:1;
}

.bmhoyre {
float:right;
text-align:left;
z-index:1;





$ b

所以它是一个大的div,用作包装,两个div和右)在里面。链接显示为块:

  a.bmlink {
display:block;
保证金:0;
padding:4px;
font-family:Tahoma,Verdana,Segoe,sans-serif;
text-transform:大写;
font-size:18px;
font-weight:bold;
letter-spacing:2px;
颜色:#08A;
text-decoration:none;
z-index:2;
}

这个div下面的标题只是一个< h3> 标签,然后有一些文字。希望这有助于您!

解决方案

您可以尝试2件事:

1)把元素溢出:隐藏

2)把元素显示:block



如果数字2因为我没有代码,所以我不能给你更多的信息,但是当margin / padding做的时候不工作,通常是因为您要将它应用到内联项目(因此编号为2),或者您有一个容器,其中的所有内容都是浮动的,因此容器将没有合适的高度(因此编号为1)


First of all, I do apologize I don't put my link here, it's a site for work and I'm not allowed. I'll post the relevant parts of my code if necessary though.

So the problem is pretty basic - i have one div with some images, and a header <h3> below where my content starts . No matter how much I try to create some space between the two, it doesn't work. I've tried margin and padding on both elements, changing between position relative and absolute, and throwing in lots of <br> tags. Nothing works!

What causes my two elements to be so attracted to each other? What may cause inability to create space between two elements?

Thanks!

Edit: here's my css code for the div:

.bmwrapper {
    width: 720px;
    position: relative;
    margin-left: auto;
    margin-right: auto;
    z-index: 1;
}

.bmvenstre {
    float: left;
    text-align: left;
    z-index: 1;
}

.bmhoyre {
    float: right;
    text-align: left;
    z-index: 1;
}

So it's one big div that acts as a wrapper, and two divs (left and right) inside. The links are displayed as blocks:

a.bmlink {
    display: block;
    margin: 0;
    padding: 4px;
    font-family: Tahoma, Verdana, Segoe, sans-serif;
    text-transform: uppercase;
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #08A;
    text-decoration: none;
    z-index: 2;
}

The header below this div is just a <h3> tag, then there's some text. Hope this helps!

解决方案

You can try 2 things:

1) Put the elements overflow:hidden

2) put the elemnts display:block

If number 2 messes up with your design, try putting them float:left;

Since I don't have the code I can't give you more information, but when margins/paddings do not work, it is usually because you are either applying it to an Inline item (hence number 2) or you have a container where everything inside is floating, so the container won't have the proper height (hence number 1)

这篇关于保证金不起作用?两个元素之间需要空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆