CSS - 如何在此页面上正确对齐星形

时间:2013-06-06 21:55:27

标签: html css vertical-alignment

我在IE 9和Opera浏览器方面遇到困难只是为了对齐星星。

我使用以下HTML:

<div class="fullwidth">
    <div class="floatleft star">&#9733;</div>
    <h3 class="icontxt">Co-Hosts</h3>
</div>

以下CSS:

.floatleft
{
    float: left;
}

.fullwidth
{
    width: 100%;
}

h3
{
    margin: 0;
    text-align: left;
    font-family: "GearedSlab-Regular", "Geared Slab Regular", "geared_slabregular";
    text-transform: uppercase;
    color: #212D3B;
    letter-spacing: .1em;
    font-size: 1.5em;
    line-height: 1.7em;
}

h3.icontxt
{
    padding-left: 1.5em;
}

.star
{
    font-size: 1.4em !important;
    color: #A92A23;
}

好的,所以Chrome,Firefox和Safari都会这样呈现(我在所有浏览器中都需要它):

This looks exactly the way I need it to look

但是,如果你在IE 9和/或Opera中看到它,它看起来像这样:

The Star is too high

明星太高了,需要与文字保持一致:“CO-HOSTS”

我在这里做错了吗?如何为IE,Chrome,Opera,Safari和Firefox普遍做到这一点?这太令人沮丧了!

1 个答案:

答案 0 :(得分:3)

How about this

.floatleft
{
    float: left;
}

.fullwidth
{
    width: 100%;
}

h3
{
    margin: 0;
    text-align: left;
    font-family: "GearedSlab-Regular", "Geared Slab Regular", "geared_slabregular";
    text-transform: uppercase;
    color: #212D3B;
    letter-spacing: .1em;
    font-size: 1.5em;
    line-height: 1.7em;
}

h3.icontxt
{
    padding-left: 1.5em;
}

.star
{
    line-height: 1.7em;
    font-size: 1.4em !important;
    color: #A92A23;
}