简体   繁体   English

使用@ font-face时,Firefox和IE中的负顶边距

[英]Negative top margin in firefox and IE when using @font-face

I've been developing a website in Google Chrome and finally decided to see what it looked like in IE and Firefox. 我一直在使用Google Chrome浏览器开发网站,最后决定在IE和Firefox中查看外观。 To my astonishment, Firefox and Internet Explorer both had the same issue compared to chrome. 令我惊讶的是,与chrome相比,Firefox和Internet Explorer都有相同的问题。 When using @font-face to import a font Google Chrome displays things the way I want it to, but Firefox and Internet Explorer both show the font with an imaginary "negative top margin". 使用@ font-face导入字体时,Google Chrome会以我想要的方式显示内容,但是Firefox和Internet Explorer都以假想的“负顶边距”显示该字体。 I attached some screenshots as it is a bit hard to explain. 我附上了一些截图,因为有点难以解释。

Google Chrome 谷歌浏览器

谷歌浏览器

Firefox 火狐浏览器

火狐浏览器

Internet Explorer IE浏览器

Internet Explorer http://img846.imageshack.us/img846/3021/a78c216586e54bc2b05d2a8.png Internet Explorer http://img846.imageshack.us/img846/3021/a78c216586e54bc2b05d2a8.png

Google Chrome 谷歌浏览器

Google Chrome http://prntscr.com/o2w3r/direct 谷歌浏览器http://prntscr.com/o2w3r/direct

Firefox 火狐浏览器

Firefox http://prntscr.com/o2w1e/direct Firefox http://prntscr.com/o2w1e/direct

Internet Explorer IE浏览器

Internet Explorer http://prntscr.com/o2vyb/direct Internet Explorer http://prntscr.com/o2vyb/direct

Does anyone have any idea what could be causing this? 有谁知道这可能是什么原因? I haven't implemented browser-fix so all the CSS for the navigation bar is: 我尚未实现浏览器修复,因此导航栏的所有CSS为:

<div id="nav">
    <ul>
        <li>
            <a href="#main">HOME</a>
        </li>
        <li>
            <a href="#news">NEWS</a>
        </li>
        <li>
            <a href="#events">EVENTS</a>
        </li>
        <li>
            <a href="#about">ABOUT</a>
        </li>
        <li>
            <a href="#music">MUSIC</a>
        </li>
        <li>
            <a href="#study">STUDY</a>
        </li>
        <li>
            <a href="#gallery">GALLERY</a>
        </li>
        <li>
            <a href="#shop">SHOP</a>
        </li>
        <li>
            <a href="#contact">CONTACT</a>
        </li>
    </ul>
</div>

#nav a {
    height: 60px;
    margin-bottom: 0px;
    width: 105px;
    display: block;
    line-height: 60px;
    text-align: center;
    font-family: bebas;
    text-decoration: none;
    color: #555555;
    font-size: 25px;
}

Markup for the events list is: 事件列表的标记为:

<div class="entry">
    <div class="date">
        <div class="day">15</div>
        <div class="month">Nov</div>
    </div>      
    <div class="location">
        <div class="city">Melbourne</div>
        <div class="club">St Judes Anglican Church</div>
    </div>  
    <div class="clear"></div>
</div>

#events .entry{
    text-transform: uppercase;
    font-family: bebas;
    font-size: 30px;
    color: #555555;
    word-spacing: 4px;
    border-top: 2px solid #4A3948;
}
.city{
    font-size: 40px;
}

.location{
    padding-left:10px;
}
.day{
    font-size: 65px;
    line-height: 55px;
}
.date{
    text-align: center;
    width: 95px;
    border-right: 4px solid;
}
.club{
    font-size: 28px;
    line-height: 31px;
}

Does anyone have any information on this issue? 是否有人对此问题有任何信息?

在这里,“#nav a”而不是高度尝试删除高度并使用padding:20px 25px;

我已经根据您的字体大小提到了示例填充,您可以添加使用填充...。

如果其他所有方法都失败,您可以引入LINE-HEIGHT吗?

It was an issue with the font's metrics as Boris Zbarsky suggested in the comments. 鲍里斯·扎巴尔斯基(Boris Zbarsky)在评论中建议,这是字体规格的问题。 I downloaded a fresh copy of the typekit from a specialised @font-face website and its working now! 我从专门的@ font-face网站下载了该字体工具包的新副本,现在可以正常使用!

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

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