如何在链接中垂直居中文本

时间:2015-12-23 16:22:24

标签: html css

HTML:

m_x(++m_i)

小提琴:https://jsfiddle.net/nkvpqpy1/

如何将"更新个人资料"文本在链接中垂直居中。

4 个答案:

答案 0 :(得分:3)

使用line-height: 2.5em

    .zocial span
    {
        padding: .5em 0 0 0;
        line-height: 2.5em;
    }

https://jsfiddle.net/nkvpqpy1/1/

答案 1 :(得分:2)

line-height是最佳答案,但您也可以这样做:

padding: .2em .95em 0 0;

只需添加一个轻微的顶部填充

JS Fiddle

答案 2 :(得分:1)

a span {
    padding: 0;
    vertical-align: middle;
}

答案 3 :(得分:0)

using System.Windows; using System.Windows.Controls; namespace ModalTest { public partial class MainWindow { public MainWindow() { InitializeComponent(); var modelessWindowWithNoOwner = new Window { Content = new TextBlock { Text = "modeless window" } }; modelessWindowWithNoOwner.Show(); } private void buttonShowModalWindow_OnClick(object sender, RoutedEventArgs e) { var modalWindowWithOwner = new Window { Owner = this, Content = new TextBlock { Text = "modal window" } }; modalWindowWithOwner.ShowDialog(); } } } 移除顶部填充并将其设为span

因此,请将现有规则更改为

vertical-align:middle

https://jsfiddle.net/nkvpqpy1/5/

更新了演示