简体   繁体   English

IE中的CSS按钮对齐问题

[英]CSS Buttons Alignment Problem in IE

Hi I have a problem with these buttons, they are a UL List basically, they render fine in Chrome, and Firefox, but on IE the right buttons go about -5 pixels more Top than where they should be. 嗨,我对这些按钮有疑问,它们基本上是UL列表,它们在Chrome和Firefox中呈现良好,但是在IE上,右侧按钮的顶部比应有的位置多了-5像素。

<ul id="buttonList">
                <li id="analysis">
                    <img src="images/anaylsis.png" width="210" height="34" alt="analysis" />
                </li>
                <li id="calories">
                    <img src="images/calories.png" width="211" height="34" alt="calories" />
                </li>
                <li id="ingredients">
                    <img src="images/ingredients.png" width="210" height="35" alt="ingredients" />
                </li>
                <li id="feeding">
                <img src="images/feeding.png" width="211" height="36" alt="feeding" />
                </li>
            </ul>

This is the CSS. 这是CSS。 The commented lines are what I tried before, they still don't work. 带注释的行是我之前尝试过的,但仍然无法使用。

#buttonList
{
padding: 0px;
}

#analysis
{
position: relative;
padding: 0px;
margin: 0px;
}

#calories
{
position: relative;
padding: 0px;
margin: 0px;
}

#ingredients
{
/*position: relative;
left: 220px;
top: -77px;
*/
margin-left: 220px;
margin-top: -77px;
} 

#feeding
{
/*
position: relative;
left: 220px;
top: -77px;
*/
margin-left: 220px;
margin-top: -0px;
} 

I have this code set on top 我在上面设置了此代码

* 
{
margin: 0px;
padding: 0px;
}

body
{
margin: 0px;
font-family: Helvetica, Arial, sans-serif;
} 

Why do the images have different height / width attributes? 为什么图像具有不同的height / width属性?

Surely you want images that are all the same dimensions to align them properly? 您确定要使所有尺寸相同的图像正确对齐吗?

I changed all the img height attributes to 36 (and the width s to 210 ), and used float: left and margin-right to align the images: 我将所有img height属性更改为36width s更改为210 ),并使用float: leftmargin-right对齐图像:

http://jsfiddle.net/Rm9hT/6/ http://jsfiddle.net/Rm9hT/6/

Testded in IE6 / IE7, Chrome, FF 在IE6 / IE7,Chrome,FF中测试

  #buttonList
{
    width: 430px; 
    list-style:none;
    margin:0;
    padding: 5px
}
  #buttonList li {
    margin: 5px 5px 0 0;
    display:inline;
    width: 211px;
    height: 36px
  }

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

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