文本未对齐
我创建了以下 HTML CSS 代码:
<div class="Pager">
<span class="Resume">Posts 1 to 40 of 220X</span>
<ul class="Buttons">
<li><span>123</span></li>
</ul>
<div class="Clear"></div>
</div>
.Class {clear: both;}
div.Pager {}
div.Pager span.Resume {
font-family: Arial;
font-size: 0.9em;
line-height: 1;
float: left;
}
div.Pager ul.Buttons {
float: left;
}
div.Pager ul.Buttons li {
float: left;
}
div.Pager ul.Buttons li span {
font-family: Arial;
font-size: 0.9em;
line-height: 1;
}
有谁知道为什么“123”文本显示得比之前的要低文本?
谢谢你, 米格尔
I created the following HTML CSS Code:
<div class="Pager">
<span class="Resume">Posts 1 to 40 of 220X</span>
<ul class="Buttons">
<li><span>123</span></li>
</ul>
<div class="Clear"></div>
</div>
.Class {clear: both;}
div.Pager {}
div.Pager span.Resume {
font-family: Arial;
font-size: 0.9em;
line-height: 1;
float: left;
}
div.Pager ul.Buttons {
float: left;
}
div.Pager ul.Buttons li {
float: left;
}
div.Pager ul.Buttons li span {
font-family: Arial;
font-size: 0.9em;
line-height: 1;
}
Does anyone knows why the "123" text appears lower then the previous text?
Thank You,
Miguel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将“字体样式设置 CSS”移动到最外层元素 (
div.Pager
),并仅将其放在该元素上,这样您就不必不必要地重新定义相同的内容:http://jsfiddle.net/thirtydot/85AKq/9/
这是有效的,因为
font-family
、font-size
、line-height
都是可继承的——后代可以从父元素继承这些属性。我很确定这是无关紧要的,但要使其在 jsFiddle 中关闭“标准化 CSS”时工作,请添加
margin: 0;填充:0;列表样式:无
到您的ul
:http:// jsfiddle.net/thirtydot/85AKq/10/
Move your "font style setting CSS" to the outermost element (
div.Pager
), and have it only on that element so you're not needlessly redefining the same thing:http://jsfiddle.net/thirtydot/85AKq/9/
This works because
font-family
,font-size
,line-height
are all inheritable - the descendants can inherit those properties from the parent element.I'm pretty sure this is irrelevant, but to make it work when "Normalized CSS" is turned off in jsFiddle, add
margin: 0; padding: 0; list-style: none
to yourul
:http://jsfiddle.net/thirtydot/85AKq/10/
将两个跨度上的
line-height
更改为正常对我有用以及更改
li
和ul
以删除点和间距完全修复了它。Changing the
line-height
to normal on both the spans worked for meAs well as changing the
li
andul
to remove the dot and the spacing fixed it completely.这是因为文本位于无序列表内。列表具有由浏览器确定的自动边距属性。为了让它达到相同的水平,您必须通过为列表提供
margin-top: -3px
样式来将其位置偏移到顶部,如下所示:http://jsfiddle.net/hnYUR/
It's because the text is inside an unordered list. Lists have automatic margin properties that are determined by the browser. In order to get it to go up to the same level you're going to have to offset it's position to the top by giving the list a
margin-top: -3px
style like so:http://jsfiddle.net/hnYUR/