向上移动内嵌显示的字符
我有以下面包屑菜单标记:
<div>
<span class="start-here">You are here:<span>
<a href="/">example.com</a>
<span class="raquo"> › </span>
<a href="/news">News</a>
<span class="raquo"> › </span>
Title
</div>
当所有元素都存在时,是否有一种智能方法可以将这些 ›
(.raquo
) 字符向上移动几个像素,而无需绝对定位内嵌显示?我希望这个字符比其他字符小并显示在行的中心(或向下/向上的一些像素)。
(我需要它也适用于 IE6 及更高版本)
I have the following markup for breadcrumbs menu:
<div>
<span class="start-here">You are here:<span>
<a href="/">example.com</a>
<span class="raquo"> › </span>
<a href="/news">News</a>
<span class="raquo"> › </span>
Title
</div>
Is there a smart way to move those ›
(.raquo
) characters a few pixels up without absolute positioning when all of the elements are displayed inline? I want this character to be smaller than the others and to be displayed in the center of the line (or some pixels down/up).
(I need it to work also for IE6 and up)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
对我来说效果最好
worked best for me
任何金额或单位。
它对于自定义字体和其他不正确对齐的跨度和元素等内容非常强大。我只是将它用在我从设计师那里得到的字体上。
with any amount or unit.
It is very powerful for things like custom fonts and other spans and elements that are incorrectly justified. I just used it on a font that I got from my designer.
不确定 IE6,但似乎下面的内容应该可以让您接近您想要的。
只需将
font-size
设置为您需要的任何内容即可,垂直对齐应将其设置为line-height
的中间。Not sure about IE6, but it seems like the following should get you close to what you want.
Just make
font-size
whatever you need, vertical align should set it to the middle of theline-height
.基于 @sashn 的答案,如果您想针对未来的字体大小更改进行未来验证,我会这样做...
这样位置偏移量将根据字体大小自动缩小或扩展。
Building on @sashn's answer, if you want to future-proof it against future font size changes, I would do this...
This way the position offset will automatically shrink or expand depending on font size.
您可以使用vertical-align:top; CSS 中的 font-size:x-small;。虽然很难完美地处于中间......
You can use
vertical-align:top; font-size:x-small;
in CSS. It's hard to get perfectly in the middle though...我不想这么说……但你可以使用
桌子
。我发现这是确保所有内容都垂直居中的唯一可靠方法:I hate to say this... but you could use a
table
. I've found it to be the only reliable way to make sure that everything is vertically centered in a line: