简体   繁体   English

如何在一个内部垂直对齐2种不同的字体大小<p>

[英]how to vertically align the 2 different font sizes inside a single <p>

As the title says, how should I vertically align this:- 正如标题所说,我应该如何垂直对齐: -

Need: - - | 需要: - - | - | - | - - - -

Currently the vertical alignment is by default at baseline. 目前垂直对齐默认为基线。

Currently: _ _ | 目前:_ _ | _ | _ | _ _ _ _

HTML: HTML:

<div class="moduleResult">
    <p>You have
        <span class="moduleCard">88</span>
        out of
        <span class="moduleCard">88</span>
    correct</p>
</div>

CSS: CSS:

.moduleResult{
    width:100%;
    }

p{
    font-family:'Arial';
    font-size:20px !important;
    line-height:30px;
    text-align:center;
    }

.moduleCard{
    font-size:60px !important;
    line-height:60px;
    padding:0 4px;
    }

and the text has to be aligned centred inside a < div class"moduleResult" > 并且文本必须在<div class“moduleResult”>中居中对齐

here's the Fiddle Link 这是小提琴链接

See http://jsfiddle.net/kfVGf/2/ http://jsfiddle.net/kfVGf/2/

.moduleCard{
    font-size:60px !important;
    padding:0 4px;
    display: inline-block;
    vertical-align: middle;
}

Result: 结果:

在此输入图像描述


Note: unless you have a valid reason for it, avoid to use !important 注意: 除非您有正当理由否则请避免使用!important

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM