减少HTML< UL>之间的差距和< LI>元素 [英] Reduce Gap between HTML <UL> and <LI> elements

查看:129
本文介绍了减少HTML< UL>之间的差距和< LI>元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页中有以下HTML:

I have below HTML in my web page:

Forum
<ul>
<li> Stack</li>
<li> OverFlow</li>
</ul>

下面您可以看到,我列出的项目是完美的,但两者之间存在固定的差距< UL> < LI> 元素。

And as you could see below, I get the items listed perfectly, but there is a fixed gap between <UL> and <LI> elements.

有一种方法,我可以缩小这个差距吗?例如,在附加屏幕中的论坛和堆栈文本之间存在间隙?

Is there a way, I can reduce this gap? i.e. gap between "Forum" and "Stack" text in attached screen?

推荐答案

<$ c $之间不存在间隙c> UL 和 LI 元素,但在 Forum 文本和<$ c之间$ c> UL 元素。大多数浏览器都会在某些元素(例如 UL )周围定义默认边距。

The gap does not exist between UL and LI elements, but between the Forum text and the UL element. Most browsers define a default margin around certain elements, like the UL.

您可以使用CSS消除它:

You get rid of it with CSS:

ul { margin: 0; }

,或者如果您只是想减小它,例如,这将设置0的水平边距,垂直像素为5px:

or if you just want to reduce it, for example this one will set 0 margin for horizontal, 5px for vertical:

ul { margin: 5px 0; }

这篇关于减少HTML&lt; UL&gt;之间的差距和&lt; LI&gt;元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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