0

我在使用 IE9 时遇到了一点问题,只是想不通,我在 CSS 中创建了一个带有线性渐变的按钮,它在 Chorme、Firefox 和 Safari 中完美显示,但在 IE9 中却没有

http://ubizzo.co.uk/img/ie9.png

http://ubizzo.co.uk/img/ch-fi-sa.png

第一个图片链接是 IE9,第二个图片链接是所有其他浏览器,我可以让它工作的唯一方法是如果我在 CSS 中添加 float:left 或 float:right ,如下所示,但这显然会搞砸布局,我已经尝试使用 float:none 但这也不起作用,我在一个空白的 html 文件中尝试了这个,只是为了排除任何冲突的 css 但仍然不起作用:-s

.purchase {
    margin-top: 5px;
    display: block;
    width: auto;
}

.purchase a {
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 5px 10px;
    cursor: pointer;
    border: none;
    color: #fff;
    line-height: 1em;
    width: auto;
    **float: left;**
    border-image: initial;
    text-align: center;


    border: solid 1px #189199;

    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    border-radius: 4px;

    background: -moz-linear-gradient(top, #19d7e3, #12A4B3);
    background: -webkit-gradient(linear, left top, left bottom, from(#19d7e3), to(#12A4B3));
    background: -moz-linear-gradient(top, #19d7e3, #12A4B3);

    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#19d7e3', endColorstr='#12A4B3');
}

.purchase a:hover {

    background: -moz-linear-gradient(top, #12A4B3, #19d7e3);
    background: -webkit-gradient(linear, left top, left bottom, from(#12A4B3), to(#19d7e3));
    background: -moz-linear-gradient(top, #12A4B3, #19d7e3);

    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#12A4B3', endColorstr='#19d7e3');

    color: #ffffff;
}

感谢您的帮助,亚当。

http://jsfiddle.net/gdmP8/ - 请注意,该按钮仅在您添加 float:left/right 后才会显示

4

3 回答 3

3

应用此 css thi 将适用于我在 chrome、Firefox、safari、opera、ie-7、ie-8、ie-9 中签入的所有浏览器

background: #12a4b3; /* Old browsers */
background: -moz-linear-gradient(top,  #12a4b3 0%, #19d7e3 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#12a4b3), color-stop(100%,#19d7e3)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #12a4b3 0%,#19d7e3 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #12a4b3 0%,#19d7e3 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #12a4b3 0%,#19d7e3 100%); /* IE10+ */
background: linear-gradient(top,  #12a4b3 0%,#19d7e3 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#12a4b3', endColorstr='#19d7e3',GradientType=0 ); /* IE6-9 */
于 2012-06-13T10:10:49.767 回答
0

IE 9 中的浮动问题通常是由于标头错误造成的。检查这个:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

取自IE9 Float with Overflow:Hidden and Table Width 100% Not Displaying (不确定是否重复)

你可能应该使用现在的标准linear-gradient(或者至少-ms-linear-gradient-o-linear-gradient不是仅仅使用 moz 和 webkit 特定的渐变)。

于 2012-06-13T09:44:28.967 回答
0

你在 Opera 中也会遇到同样的问题,你为什么不坚持一个简单的 IE 按钮图像翻转?

于 2012-06-13T09:45:00.953 回答