文本上出现奇怪的垂直空间
我对一些 @font-face 文本遇到了一个奇怪的问题,其中文本中包含一些奇怪的填充(或至少是垂直空间)。它引起了问题,因为我希望文本以某种方式定位,但不能让它与其他东西重叠。这是所发生情况的图片:
正如您所看到的,当选择文本时,文本会与部分导航重叠其上方的栏。我尝试过调整行高、填充、边距,以及我能想到的任何东西。这是相关的 CSS,有人对如何使行的高度接近实际文本的高度有建议吗?
*{ margin: 0; padding: 0; }
h1#logo { font: 350px/.95 'Bebas Neue'; color: #DDD; text-align: center; margin: 1px 0; }
编辑:这是问题的一个实例:http://codezroz。 com/stuff/hello.html
I'm having a strange issue with some @font-face text where there is some strange padding (or at least vertical space) included with the text. It is causing problems because I want to text to be positioned a certain way but can't have it overlapping other things. Here is a picture of what is occurring:
As you can see when the text is selected, the text overlaps some of the navigation bar above it. I have tried adjusting the line height and padding, margins, anything I can think of. Here is the relevant CSS, does anybody have a suggestion as to how I can get the height of the line to be around the height of the actual text.
*{ margin: 0; padding: 0; }
h1#logo { font: 350px/.95 'Bebas Neue'; color: #DDD; text-align: center; margin: 1px 0; }
EDIT: Here is a live example of the problem: http://codezroz.com/stuff/hello.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以前从未见过
/.95
语法,但经过一些测试后,现在我相信它的工作原理如下:行高 = 0.95 * 字体大小 = 332.5
所以我认为这是你的问题,字体比线高
在 H1 上添加
overflow:hidden;
应该就足够了never seen the
/.95
syntax before, but after a few tests now i belive it works like:line-height = 0.95 * font-size = 332.5
so i think that's your problem, the font is taller than the line
adding
overflow: hidden;
on the H1 should be enough好吧,将
overflow:hidden
应用于h1#logo
可以阻止选择突出显示渗入元素外部的区域。另请记住,您可以使用
:selection
伪元素更改所选文本的颜色。Well, applying
overflow: hidden
toh1#logo
stopped the selection highlight from bleeding into areas that were outside the element.Also remember that you can use the
:selection
pseudo-element to change the color of the selected text.