Html CSS:减少文本的行距?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18151124/
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
CSS: reducing line spacing of text?
提问by user2649496
I am having difficulty reducing the spacing between lines of text with CSS line-height (or height - I've tried both).
我很难用 CSS 行高(或高度 - 我都试过)来减少文本行之间的间距。
I have a small bit of text and the spacing is off. I've tried modifying the styles that (appear to) apply, and also enclosing the text in a <span>...</span>
and explicitly declaring the style. Nothing seems to work.
我有一小段文字,间距已关闭。我尝试修改(似乎)应用的样式,并将文本括在 a 中<span>...</span>
并明确声明样式。似乎没有任何效果。
The site is a Wordpress site using the Pagelines "lite" theme. The URL is http://stage.dsthree.comand the issue is on the front page (you can see it in the fourth column of text, just below the "email subscribe" box in the small text - the line spacing for that text is off. This site will not allow me to post a screenshot, as I am new here.
该站点是一个使用 Pagelines “lite” 主题的 Wordpress 站点。URL 是http://stage.dsthree.com并且问题在首页上(您可以在第四列文本中看到它,就在小文本中的“电子邮件订阅”框下方 - 行距text is off。这个网站不允许我发布截图,因为我是新来的。
I've reduced the line-height to 1% and to 1px to no effect.
我已经将 line-height 减少到 1% 和 1px 没有效果。
Any help, directions or suggestions on how to reduce the whitespace is much appreciated!
非常感谢有关如何减少空白的任何帮助、指示或建议!
回答by Mr Lister
Inline elements don't honour properties such as line-height
; they take on the line height of the nearest block parent.
内联元素不支持诸如line-height
; 之类的属性。它们采用最近块父级的行高。
See Fiddle
见小提琴
Solution: remove the line-height from the body, or turn the span into a block (i.e. make it a div; don't give display:block
to the span).
解决方案:从 body 中移除 line-height,或者将 span 变成一个块(即使它成为一个 div;不要给display:block
span)。
回答by Shivam
回答by benteh
You have a line-height: 21px;
In the body. Remove this, and it should work.
你有一个line-height: 21px;
在体内。删除它,它应该可以工作。