问题描述
有人向我展示了一个使用div标签显示包含背景图片的文本的html
Someone shows me a html to use div tag to show some text with background image included
<div class='main'>
<div class='img1'>
SOME TITLE TEXT
</div>
</div>";
<div class='img2'>"
SOME DESCRIPTION TEXT HERE
</div>"
此处img1和img2类包含两个背景图像,并且img1旁边将显示img2的对应div(无间隙).我需要重复整个模式几次,以显示内容不同但格式相同的内容.
Here the class img1 and img2 include two background images and the corresponding div for img2 will be shown next to img1 (without gap). I need to repeat the whole pattern couple times to show something with different content but same format.
<!-- GROUP 1 -->
<div class='main'>
<div class='img1'>
SOME TITLE TEXT 1
</div>
</div>";
<div class='img2'>"
SOME DESCRIPTION TEXT HERE 1
</div>"
<!-- GROUP 2 -->
<div class='main'>
<div class='img1'>
SOME TITLE TEXT 2
</div>
</div>";
<div class='img2'>"
SOME DESCRIPTION TEXT HERE 2
</div>"
但是我发现,如上所述,任何两个组之间都没有分隔.坦白说,我真的没有html的经验,我只是从别人那里复制代码.但是在网上搜索之后,我找到了
命令,我尝试在组之间添加该标签,但是中断似乎超出了我的预期.还有其他方法可以插入间隙较小的分隔符吗?
But I found that there is no separation between any two groups as shown above. Frankly, I really have no experience in html, I just copy the code from someone else. But after searching online, I find the
command, I try to add that tag in between the groups but it seems that the break is too much than I expect. Is there any other way to insert separation with smaller gap?
推荐答案
您可以像这样从top
和bottom
中给出margin
:
You can give margin
from top
and bottom
like this:
margin: 10px 0;
以上将在顶部和底部应用10px
边距.您还可以使用单个属性,例如margin-top
和margin-bottom
.
Above will apply 10px
margin from top and bottom. You can also use individual properties such as margin-top
and margin-bottom
.
这篇关于在div之前和之后添加换行符的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!