CSS - Padding in IE issue?

梦想的初衷 提交于 2019-12-13 06:20:14

问题


I'm having trouble width some padding. In Chrome/Firefox it looks different than in Internet Explorer. In Internet Explorer it is much bigger. It is the

.menu ul li{
    display:inline;
    padding-right:60px;
    margin:0;
} 

Why?

.menu{
    background-color:#000;
    height:35px;
    padding-top:15px;
    color:#fff;
    font-size:18px;
}

.menu ul{
    padding:0; 
    margin:0;
    list-style-type:none;
}

.menu ul li{
    display:inline;
    padding-right:60px;
    margin:0;
}

.menu a:link{
    color:#fff;
}

.menu a:active{
    color:#fff;
}

.menu a:hover{
    color:#fff;
}

.menu a:visited{
    color:#fff;
}

I really hope someone can help :)


回答1:


IE calculates padding as part of height/width, other browsers interpret it height/width plus padding. So try to give only height/width or padding/margin.




回答2:


if you want to unify the box model of ie with those of other browsers you can always use the box-sizing CSS3 property. it is not supported in older version of ie, so it's best to use border-box in chrome, ff, etc. than to use content-box for ie. for further reading look here - http://www.css3.info/preview/box-sizing/




回答3:


Because the different browser have different font styling even though you set the font-styling. Similarly ie have different front size. so you can write the code for IE.

Here the link to help how to specific css in ie only.

http://css-tricks.com/how-to-create-an-ie-only-stylesheet/



来源:https://stackoverflow.com/questions/13288991/css-padding-in-ie-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!