Html 在图像之间添加空间

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9278990/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:32:34  来源:igfitidea点击:

adding space between images

htmlcss

提问by Nigel

How can I add some space to the following images Meaning that I want horizontal space in between the following images

如何为以下图像添加一些空间意味着我希望在以下图像之间有水平空间

<p class="menusomething">In-game Imagery</br>
<a href="R.jpg"><img src="age1.jpg" width="200" height="150"/>          </a></br>
<a href="Re2.jpg"><img src="age2.jpg" width="200" height="150"/>   </a></BR>
<a href="Ri.jpg"><img src="Re3.jpg" width="200" height="150"/></a></BR>
<a href="Ri4.jpg"><img src="e4.jpg" width="200" height="150"/></a></BR>
</p>

and the css code

和 css 代码

p.menusomething{background: white;
   margin: auto;
   margin-top: 200px;
   margin-left: 10px;
   padding: 10px;
   width: 200px;}

回答by Mohammed Swillam

you were targeting the container of your images, not the images themselves. to fix this, simply add any of the following CSS lines to your file

您的目标是图像的容器,而不是图像本身。要解决此问题,只需将以下任何 CSS 行添加到您的文件中

p.menusomething a>img
{
   margin-top:20px; /*to have the space above the image*/
   margin-bottom:20px; /*to have the space under the image*/
}

just one of them should do the job, let me know if this is what you need.

只有其中一个应该完成这项工作,如果这是您需要的,请告诉我。

check this Live demo for more details: http://jsfiddle.net/3jApT/3/

查看此现场演示以了解更多详细信息:http: //jsfiddle.net/3jApT/3/

回答by Dejan.S

p.menusomething a img {
margin: 0 10px 0 0;
}

回答by CompanyDroneFromSector7G

p.menusomething img 
{
    margin-bottom:10px;
}

回答by Praveen Vijayan

.menusomething img {
 display:block;
 margin:10px 0 10px 0;
}

回答by sadeq alshaar

add hspace="20" for a foto's

为照片添加 hspace="20"

<p class="menusomething">In-game Imagery</br>
<a href="R.jpg"><img src="age1.jpg" width="200" height="150" hspace="20" />          </a></br>
<a href="Re2.jpg"><img src="age2.jpg" width="200" height="150" hspace="20" />   </a></BR>
<a href="Ri.jpg"><img src="Re3.jpg" width="200" height="150" hspace="20" /></a></BR>
<a href="Ri4.jpg"><img src="e4.jpg" width="200" height="150" hspace="20" /></a></BR>
</p>