水平导航 - 如何垂直对齐- 的内容
我有一个用 CSS 设计的水平
样式。效果很好,可以滚动所有内容,但是,列表的高度为 50px,我需要将其放置在垂直中间的链接中。由于某种原因,我不知道该怎么做...相关代码在这里: http://jsfiddle .net/XPFMB/
如何使“ssss”链接转到灰色条的中间?
I have a horizontal <ul>
styled with CSS. Works nice, rolloevers everything, however, the list has a height of 50px and I need to position the in the links in the vertical middle. For some reason, I can't figure out how to do that...
The relevant code is here: http://jsfiddle.net/XPFMB/
How to make the "ssss" links go to the middle of the grey bar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
line-height: 50px;
添加到.nav ul li a
的 CSS 中Add
line-height: 50px;
to your CSS for.nav ul li a
将 line-height 添加到
li
的 CSS:JS Fiddle demo。
不过,如果您的文本足够长到可以运行到第二行,这将导致问题;但是考虑到这一点,您可以在
a
元素上使用min-width
(而不是width
),并且然后将white-space: nowrap
添加到ul
和li
:JS Fiddle 演示。
它仍然不完美;但它确实减少了通过使用太长的链接文本来破坏布局的可能性。
Add line-height to the
li
's CSS:JS Fiddle demo.
This will cause problems if your text is long enough to run to a second line, though; however to account for that you could use
min-width
(instead ofwidth
) on thea
elements, and then addwhite-space: nowrap
to both theul
and theli
:JS Fiddle demo.
It's still not perfect; but it does reduce the likelihood of the layout breaking by using link-text a few characters too long.