简体   繁体   English

IE8的边界半径

[英]Border Radius for IE8

I have a problem with border radius on IE8, till now I used pie.js but I don't recommend this js library because is buggy. 我在IE8上有边界半径的问题,到现在为止我使用了pie.js,但我不推荐这个js库,因为它是错误的。 If you have a small site with not many html pages, it is more than ok to use that library, but if you have a heavy application in which many different frameworks are used, then is impossible to use that. 如果你有一个没有多少html页面的小网站,那么使用该库是可以的,但如果你有一个繁重的应用程序,其中使用了许多不同的框架,那么就不可能使用它。 Same behavior for CurvyCorners or other mega libraries. CurvyCorners或其他大型库的相同行为。

So if anyone can help me with a small jQuery or javascript plugin to do just border-radius on IE 8 I'll be grateful for life. 因此,如果任何人都可以帮助我使用一个小的jQuery或javascript插件来做IE 8上的border-radius,我将感激生命。

Try this: 试试这个:

requires: 要求:

<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>

Javascript: 使用Javascript:

$('.box').corner();

HTML: HTML:

<div class="box">Hello</div>

CSS: CSS:

box{
  width:150px;
  height:28px;
  padding:10px;
}

more examples: http://jquery.malsup.com/corner/ 更多例子: http//jquery.malsup.com/corner/

Short of using the libraries that you described in your question, I don't think you can do curved corners in IE8. 如果没有使用你在问题中描述的库,我认为你不能在IE8中做弯角。

If you really wanted them, you could probably use an image to give the curved corner effect, at the cost of increased bandwidth and messy code. 如果你真的想要它们,你可能会使用图像来提供弯曲的角落效果,代价是增加带宽和杂乱的代码。

According to Microsoft : 根据微软的说法:

Other Rounded Corners Solutions 其他圆角解决方案

We would like to point out the abundance of alternate solutions available on the Web. 我们想指出网上提供的大量替代解决方案。 In addition to individual rounded corners solutions, there are also sites with frequently updated lists of rounded corners solutions that are compatible with multiple versions of Internet Explorer and other browsers. 除了单独的圆角解决方案之外,还有一些站点具有经常更新的圆角解决方案列表,这些解决方案与多个版本的Internet Explorer和其他浏览器兼容。

Listed here are a few of our favorite sites for aggregated rounded corners solutions. 这里列出了一些我们最喜欢的聚合圆角解决方案的网站。 They are presented in no particular order, and the inclusion of any link does not imply endorsement by Microsoft of the site. 它们没有特别的顺序,并且包含任何链接并不意味着Microsoft认可该网站。

Check out this post: http://www.smashingmagazine.com/2010/04/28/css3-solutions-for-internet-explorer/ 看看这篇文章: http//www.smashingmagazine.com/2010/04/28/css3-solutions-for-internet-explorer/

It covers specifically rounded corners and box shadow in IE7/8. 它涵盖了IE7 / 8中特别圆角和框阴影。

and also below with so many examples 以及如此多的例子

http://blue-anvil.com/jquerycurvycorners/test.html http://blue-anvil.com/jquerycurvycorners/test.html

I have used the border-radius.htc in the past. 我过去使用过border-radius.htc

The only pain is that the CSS Urls are relative to the CSS file. 唯一的痛苦是CSS Urls是相对于CSS文件的。 HTC are relative to the page. HTC是相对于页面的。

you can download the demo here. 你可以在这里下载演示。

Why don't you use css' :before and :after pseudo classes to add curved corners. 为什么不使用css':before和:after伪类来添加弯角。

Your comment on Tom Will's answer suggested that you have a lot of form inputs right? 您对Tom Will的回答的评论表明您有很多表格输入吗?

Well I assume that they will be mostly uniform in width. 我认为它们的宽度大多是均匀的。

Just create some classes like curved-std-width , curved-lge-width , curved-sml-width and then you can do this in your CSS: 只需创建一些类,如curved-std-widthcurved-lge-widthcurved-sml-width ,然后你可以在CSS中执行此操作:

.curved-std-width:before {
  height: 5px;
  background: url('curved-top-5px.png');
}

.curved-std-width:after {
  height: 5px;
  background: url('curved-bottom-5px.png');
}

Something like that should work pretty well without you having to go and add endless html before and after form inputs. 这样的东西应该可以很好地运行,而不必在表单输入之前和之后添加无限的html。

Otherwise you can probably do it using jQuery as well: 否则你也可以使用jQuery来做到这一点:

$(':input').before('<div class="left-top-corner"></div><div class="right-top-corner"></div>').after('<div class="left-bottom-corner"></div><div class="right-bottom-corner"></div>');

And then style appropriately. 然后风格恰当。

Why don't you use jQuery's corner plugin ? 你为什么不使用jQuery的角落插件

You can easily apply corners to any element with a specific classname or ID; 您可以轻松地将角应用于具有特定类名或ID的任何元素; for example: 例如:

$("#box1").corner();

It also allows you to decorate or modify the type of corner effect you want adorning your elements. 它还允许您装饰或修改您想要装饰元素的角落效果类型。

You can also use other JavaScript solutions like CurvyCorners or even some CSS solutions . 您还可以使用其他JavaScript解决方案,如CurvyCorners甚至一些CSS解决方案 Another option is to use JavaScript to wrap <div> elements your form inputs and use CSS's background-image to emulate the look of rounded corners. 另一种选择是使用JavaScript来包装表单输入的<div>元素,并使用CSS的背景图像来模拟圆角的外观。 For instructions on this last solution, see this tutorial . 有关此最后一个解决方案的说明,请参阅本教程

This is ugly but might work if you know beforehand the background color of the input fields (which can be a problem with submit buttons): http://jsfiddle.net/563c5/1/ 这很难看但如果您事先知道输入字段的背景颜色(这可能是提交按钮的问题)可能会有效: http//jsfiddle.net/563c5/1/

I have no idea how it will behave when rendering lots of input fields in an average computer. 我不知道在普通计算机中渲染大量输入字段时它会如何表现。

IE8 supports inline CSS images, and you need only 1 small image for all four rounded corners. IE8支持内联CSS图像,并且所有四个圆角只需要1个小图像。 Any solution relying on corner images may actually require just a few extra bytes of bandwidth. 任何依赖角落图像的解决方案实际上可能只需要几个额外的带宽字节。

I would recommend giving Modernizr a go, the great thing about it is you can use it to substitute most (if not all) unsupported CSS3 in older browsers. 我建议给Modernizr一个去,关于它的好处是你可以使用它来替换旧浏览器中大多数(如果不是全部)不受支持的CSS3。 I have used it on a number of large web apps without any dramas. 我已经在许多大型网络应用程序上使用它而没有任何戏剧性。

You can also look at the jQuery UI library that I believe has some rounded corners scripts. 您还可以查看我相信有一些圆角脚本的jQuery UI库

I hope this helps... good luck! 我希望这有帮助...祝你好运!

you should use the alternate pie.htc, its similar thing but less buggy, and either way i don't recommend it. 你应该使用替代的pie.htc,它的类似的东西,但更少的错误,无论哪种方式,我不推荐它。

Heavy use of css3 elements on these non css3 comply browsers, don't perform good, chances is that their system are not up to date too causing them extremely laggy. 在这些非css3符合浏览器的情况下大量使用css3元素,表现不佳,很可能是因为他们的系统不是最新的,导致它们极其迟钝。 So it is good for them to degradation to a normal corner. 因此,他们退化到正常角落是有好处的。

If you really want it to look good on ie, you best of using image sprite backgrounds, or you going to change to drive away a number of your visitors for lagging issues. 如果你真的希望它看起来很好,即你最好使用图像精灵背景,或者你会改变以驱逐一些访问者以解决滞后问题。

Not sure if it was covered by previous contributors, but I used mainly dd_roundies library, and for rounded corners alone it worked ok. 不确定它是否被之前的贡献者所覆盖,但我主要使用dd_roundies库,而且仅使用圆角就可以了。 Mixing corners with IE filters usually was too much to ask though. 虽然使用IE过滤器混合角落通常太多了。

你试过这个: http//jquery.malsup.com/corner/

Use this : http://css3pie.com/ 使用此: http //css3pie.com/

PIE makes Internet Explorer 6-9 capable of rendering several of the most useful CSS3 decoration features. PIE使Internet Explorer 6-9能够呈现几个最有用的CSS3装饰功能。

Supported CSS3 Features 支持的CSS3功能

border-radius
box-shadow
border-image
multiple background images
linear-gradient as background image

Just another JavaScript-based solution: Nifty Corners Cube . 只是另一个基于JavaScript的解决方案: Nifty Corners Cube It is released as GNU GPL and doesn't need jQuery. 它作为GNU GPL发布,不需要jQuery。

Use this code to get rounded corner in IE 6+ 使用此代码在IE 6+中获得圆角

<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>
    $('#logo-navsection').corner( function() {
        $("this").css("border-top", "0px 0px opx 10px")                
    });
</script>

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

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