CSS在IE9中运行良好但在IE8中完全搞砸了

时间:2013-02-22 08:09:34

标签: css internet-explorer internet-explorer-8

enter image description here

我在IE8中没有出现边框半径和背景渐变的样式。 IE8中整个容器的大小也不同。

我尝试过CSS PIE,但也无法正常工作。

期待在此问题上获得任何帮助。请帮帮我。

提前感谢大家的提示。

.Quor_Widget_buttondescription0  //Add To Order Button
{

position:relative;
width:90%;
font-size: 24px;
height:47px;
overflow:hidden;
margin:8px 8px 5px;
border:1px solid #000000;
text-align: center;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border-radius:10px;
-moz-box-shadow:0 0 3px rgba(0,0,0,0.5);
-webkit-box-shadow:0 0 3px rgba(0,0,0,0.5);
box-shadow:0 0 3px rgba(0,0,0,0.5);
color:#000000;
font:bold, Helvetica, Arial, sans-serif;
cursor:pointer;
background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8bGluZWFyR3JhZGllbnQgaWQ9Imc0NjEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iMCUiIHkxPSIwJSIgeDI9IjAlIiB5Mj0iMTAwJSI+CjxzdG9wIHN0b3AtY29sb3I9IiM2N0JBNjciIG9mZnNldD0iIi8+PHN0b3Agc3RvcC1jb2xvcj0iIzBGQTkwRiIgb2Zmc2V0PSIiLz4KPC9saW5lYXJHcmFkaWVudD4KPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNnNDYxKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(#0FA90F, #67BA67);
behavior: url(PIE.htc);

display: inline-block;

}

//选择按钮 - 尺寸标记

.segmented-button-count3 {
background: transparent;
padding: 1px;
}
.segmented-button-count3 input[type="radio"] {
width: 0px;
height: 0px;
display: none;
}
.segmented-button-count3 label {
width:33.3%;
height:20px;
padding-top: 4px;
padding-bottom: 1px;
overflow: hidden;
white-space: nowrap;
display: block;
text-overflow: ellipsis;
display: -moz-inline-box;
-moz-box-orient: vertical;
display: inline-block;
vertical-align: middle;
vertical-align: auto;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
-khtml-border-radius: 10px;
border-radius: 10px;
text-shadow: white;
background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8bGluZWFyR3JhZGllbnQgaWQ9ImczNjEiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iMCUiIHkxPSIwJSIgeDI9IjEwMCUiIHkyPSIxMDAlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0ZCRkJGQiIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iI0M5QzlDOSIgb2Zmc2V0PSIxIi8+CjwvbGluZWFyR3JhZGllbnQ+CjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZzM2MSkiIC8+Cjwvc3ZnPg==);
background-repeat: no-repeat;
background-size:100%; 
-webkit-box-shadow: inset 0 -4px 7px rgba(0,0,0,0.15), 0 1px 0 rgba(255,255,255, 0.3), inset 0 1px 0 rgba(255,255,255, 0.3);  
-moz-box-shadow: inset 0 -8px 10px rgba(0,0,0,0.15), 0 1px 0 rgba(255,255,255, 0.3), inset 0 1px 0 rgba(255,255,255, 0.3);  
box-shadow: inset 0 -8px 10px rgba(0,0,0,0.15), 0 1px 0 rgba(255,255,255, 0.3), inset 0 1px 0 rgba(255,255,255, 0.3); 
background: -moz-linear-gradient(#fbfbfb, #c9c9c9);
border: 1px solid #b2b2b2;
color: 000000;
font-size: 13px;
cursor: pointer;
font-family: Helvetica;
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
-o-border-radius: 0px;
-ms-border-radius: 0px;
-khtml-border-radius: 0px;
border-radius: 0px;
margin-right: -5px;
}
.segmented-button-count3 label {
*display: inline;
}
.segmented-button-count3 label:hover {
-moz-box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);
-o-box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 5px 1px rgba(0, 0, 0, 0.1);
color: #333333;
}
.segmented-button-count3 label:active, .segmented-button-count3 label.active {
background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8bGluZWFyR3JhZGllbnQgaWQ9ImcyMDYiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iMCUiIHkxPSIwJSIgeDI9IjAlIiB5Mj0iMTAwJSI+CjxzdG9wIHN0b3AtY29sb3I9IiMyRDYyQkUiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiM2Q0E1RjUiIG9mZnNldD0iMSIvPgo8L2xpbmVhckdyYWRpZW50Pgo8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2cyMDYpIiAvPgo8L3N2Zz4=);
background-repeat: no-repeat;
background-size:100%; 
background: -moz-linear-gradient(#2d62be, #6ca5f5);
}
.segmented-button-count3 label.first {
-moz-border-radius-topleft: 10px;
-webkit-border-top-left-radius: 10px;
-o-border-top-left-radius: 10px;
-ms-border-top-left-radius: 10px;
-khtml-border-top-left-radius: 10px;
border-top-left-radius: 10px;
-moz-border-radius-bottomleft: 10px;
-webkit-border-bottom-left-radius: 10px;
-o-border-bottom-left-radius: 10px;
-ms-border-bottom-left-radius: 10px;
-khtml-border-bottom-left-radius: 10px;
border-bottom-left-radius: 10px;
}
.segmented-button-count3 label.last {
-moz-border-radius-topright: 10px;
-webkit-border-top-right-radius: 10px;
-o-border-top-right-radius: 10px;
-ms-border-top-right-radius: 10px;
-khtml-border-top-right-radius: 10px;
border-top-right-radius: 10px;
-moz-border-radius-bottomright: 10px;
-webkit-border-bottom-right-radius: 10px;
-o-border-bottom-right-radius: 10px;
-ms-border-bottom-right-radius: 10px;
-khtml-border-bottom-right-radius: 10px;
border-bottom-right-radius: 10px;
}
.segmented-button-count3 input:checked + label, .segmented-button-count3 label.selected {
background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPgo8bGluZWFyR3JhZGllbnQgaWQ9ImcyMDYiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iMCUiIHkxPSIwJSIgeDI9IjAlIiB5Mj0iMTAwJSI+CjxzdG9wIHN0b3AtY29sb3I9IiMyRDYyQkUiIG9mZnNldD0iMCIvPjxzdG9wIHN0b3AtY29sb3I9IiM2Q0E1RjUiIG9mZnNldD0iMSIvPgo8L2xpbmVhckdyYWRpZW50Pgo8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2cyMDYpIiAvPgo8L3N2Zz4=);
background-repeat: no-repeat;
background-size:100%; 
background: -moz-linear-gradient(#2d62be, #6ca5f5);
}

3 个答案:

答案 0 :(得分:2)

Internet Explorer 8没有对SVG的本机支持。它几乎不支持CSS3属性,例如border-radius

最好的解决方案可能是为IE8制作一个单独的样式表,使用自定义样式(例如JPG背景而不是SVG)并仅显示IE8。

您还应该查看Modernizr

或者,强迫用户使用真实的网络浏览器; - )

答案 1 :(得分:1)

答案:要在IE6-9中实现边框半径,框阴影和渐变背景,可以使用CSS3 PIE。正如SDC所提到的,您可能希望确保PIE.htc文件实际上已加载。一个例子:

.button {
  -webkit-border-radius: 12px;
     -moz-border-radius: 12px;
          border-radius: 12px;

  -webkit-box-shadow: #888 5px 5px 5px;
     -moz-box-shadow: #888 5px 5px 5px;
          box-shadow: #888 5px 5px 5px;

  background: #444; /* Single-color fallback */
  background: -webkit-gradient(linear, 0 0, 0 bottom, from(#444), to(#CCC)); /* Chrome, Safari 4+ */
  background: -webkit-linear-gradient(#444, #CCC); /* Chrome 10+, Safari 5.1+ */
  background: -moz-linear-gradient(#444, #CCC); /* FF 3.6+ */
  background: -ms-linear-gradient(#444, #CCC); /* IE10+ */
  background: -o-linear-gradient(#444, #CCC); /* Opera 11.10+ */
  background: linear-gradient(#444, #CCC); /* W3C */

  -pie-background: linear-gradient(#444, #CCC); /* For CSS3 PIE */
  behavior: url(PIE.htc); /* Also for CSS3 PIE */
}

最佳做法:您可能需要考虑重新编写CSS。有许多重复和不必要的属性和黑客使代码在特定的浏览器中工作。从浏览器开始一致性的一种简单方法是使用CSS重置,例如Normalize.css

答案 2 :(得分:1)

从屏幕截图中可以清楚地看到CSS3Pie根本没有运行。我建议阅读CSS3Pie网站上列出的常见问题和已知问题;看起来你可能会对其中一人犯规。

特别是,您应该检查PIE.htc文件是否正在加载,并且它正在以正确的mime类型提供。 (参见IE8的开发工具窗口,了解加载的URL)

第一点 - 如果文件根本没有加载,则可能是加载了错误的URL。当给出htc文件的相对URL时,IE可能会出错;将其更改为绝对URL是个好主意;例如/PIE.htc而不仅仅是PIE.htc。这在known issues page中进行了讨论。

第二点也在已知问题页面上讨论。某些Web服务器可能无法使用正确的mime类型提供htc文件。如果它不作为text/x-component提供,IE将完全忽略它。检查下载文件时发送的http标头。