Html 删除标题标签下方的填充
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1235134/
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
Remove padding beneath heading tag
提问by Chris Thompson
Currently I have a list that has an H3 heading above it (which I can't really remove easily, it's auto generated by a cms) and looks something like this
目前我有一个列表,上面有一个 H3 标题(我真的不能轻易删除它,它是由 cms 自动生成的),看起来像这样
Headline
|
|
List stuff
and I want to get rid of the pipes. They seem to be "built in" to the <h3>
tag, anyone have any idea what CSS property of h3 would get rid of this?
我想摆脱管道。它们似乎是“内置”到<h3>
标签中的,有人知道 h3 的什么 CSS 属性会摆脱这个吗?
回答by Jonathan
H1, H2, and H3 tags all inherently have a margin and padding added to them by browsers.
H1、H2 和 H3 标签本质上都具有由浏览器添加的边距和填充。
You can test this by putting a background on the H1, H2, and H3 tags in css and looking in different browsers.
您可以通过在 css 中的 H1、H2 和 H3 标签上放置背景并在不同的浏览器中查看来测试这一点。
To remove the "pipe spacing" you should:
要删除“管道间距”,您应该:
h3{
padding: 0px;
margin: 0px;
}
Then you can re-add whatever you would like since CSS is a one-way execution path. Consequent CSS values will overwrite base-level CSS.
然后你可以重新添加任何你想要的东西,因为 CSS 是一种单向执行路径。随后的 CSS 值将覆盖基础级 CSS。
回答by The Crazy Chimp
Another option that removes the space below the text is as follows:
删除文本下方空格的另一个选项如下:
h3
{
display:inline;
}
回答by Jeff Wilcox
Try setting the "border" style property on the H3 to
尝试将 H3 上的“边框”样式属性设置为
border:0;
It's possible that the "pipe" is actually a border on the headline, a border-right property, that you can modify or override.
有可能“管道”实际上是标题上的边框,一个边框权限属性,您可以修改或覆盖它。
Alternative: A true pipe that the CMS generates (I'm assuming you've checked the HTML source and this is not the case, but good to ask)
替代方案:CMS 生成的真正管道(我假设您已经检查了 HTML 源代码,但事实并非如此,但很高兴提问)
Can you select the text and see if it is a true pipe character, or rather just a visual element?
您可以选择文本并查看它是真正的管道字符,还是只是一个视觉元素?
Other Alternative: Some kind of CSS content property. More rare, since most browsers don't support it.
其他替代方案:某种 CSS 内容属性。更罕见,因为大多数浏览器不支持它。
回答by Ronie
In Addition to @Jonathan answer, You must add:
除了@Jonathan 回答之外,您还必须添加:
p{
padding: 0px;
margin: 0px;
}
That solved my problem.
那解决了我的问题。
回答by James Skidmore
If the pipes are actual text, you're not going to be able to get rid of them without using some form of JavaScript.
如果管道是实际文本,则不使用某种形式的 JavaScript 就无法摆脱它们。
If the pipes are a background image for the H3, you can use this to get rid of them:
如果管道是 H3 的背景图像,您可以使用它来摆脱它们:
h3
{
background-image: none;
}