我在IE中使用JQuery库“圆角”时遇到了问题。我所要做的就是在Internet Explorer中模拟一个div的边框半径。我已经让这个插件在Firefox中工作了,但我认为这是因为这个插件利用了CSS属性。我也让它在IE中工作,但只能在基本的DIVs上工作。
这是该插件的主页:http://jquery.malsup.com/corner/
代码如下:
CSS
<style>
#mydiv { /*basic CSS for the DIV*/
border: 1px solid #76B4EA;
border-bottom: none;
box-shadow: inset -10px 10px 30px #e0e0e0, 2px -2px 1px #707070;
background: #fff;
width: 200px;
height: 80px;
margin-top: 21px;
z-index: 3;
margin-left:2px;
position: absolute
}
#ie-shadow { /*code for a cross-browser shadow*/
display: none;
}
</style>
<!--[if lte IE 8]>/*more code for the cross-browser shadow*/
<style>
#ie-shadow {
display: block;
position: absolute;
top: 17px;
left: 2px;
width: 200px;
height: 80px;
z-index: 1;
background: #000;
filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='2', MakeShadow='true', ShadowOpacity='0.40');
}
</style>
<![endif]-->HTML
<div id="mydiv"></div>
<div id="ie-shadow"> </div>Javascript
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.corner.js"></script>
<script type="text/javascript">
$('#mydiv').corner("rounded top 10px keep cc:transparent");
</script>发布于 2012-04-04 01:45:09
我将推荐一个更好的选择: PIE.htc。
请在此处下载:http://css3pie.com/
使用
将PIE.htc文件解压缩到根目录。在CSS中,您可以执行以下操作:
.round-em {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
behavior: url('PIE.htc');
}注意: PIE.htc的位置是相对于HTML文件的,而不是相对于CSS文件的。此外,您只能使用border-radius的速记形式。例如,当使用针对IE的hack时,您不能指定border-top-left-radius。
你可以更进一步,添加IE条件(PIE.htc与IE9+不能很好地配合):
.round-em {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}<!--[if lt IE 9]> .round-em { behavior: url('PIE.htc'); } <![endif]-->
编辑
由于您不能跨域加载PIE.htc脚本,因此可以使用PIE.js。这是链接:http://css3pie.com/documentation/pie-js/
这里有一个托管版本:http://cdnjs.cloudflare.com/ajax/libs/css3pie/1.0beta5/PIE.js
如何使用PIE.JS
首先,通过IE条件调用脚本:
<!--[if lt IE 9]> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/css3pie/1.0beta5/PIE.js"></script> <![endif]-->
接下来,使用jQuery遍历将round-em作为类的每个元素。然后,使用PIE.attach方法并作为参数传入this上下文。
$(function() {
if (window.PIE) {
$('.rounded').each(function() {
PIE.attach(this);
});
}
});https://stackoverflow.com/questions/9998105
复制相似问题