简体   繁体   English

JavaScript带有透明背景的圆角

[英]JavaScript rounded corners with transparent background

I'm looking for a JavaScript library that can create round corners on div tags with a transparent background, such that the background colour/image of the parent element is visible at the rounded corners. 我正在寻找一个JavaScript库,该库可以在具有透明背景的div标签上创建圆角,以使父元素的背景颜色/图像在圆角处可见。 For an example of rounded corners without a transparent background, have a look at the left menu on this page . 有关没有透明背景的圆角示例,请查看此页面上的左侧菜单。 Notice that the background of the parent element is not shown at the corners of the menu items. 请注意,父元素的背景未显示在菜单项的角落。

I need this to work in IE7+ and FF3+ (ideally the other browsers too), and I'd prefer a JQuery plugin. 我需要此功能才能在IE7 +和FF3 +(也希望是其他浏览器)中工作,并且我更喜欢JQuery插件。

Does anyone have any good resources or plugins that would help? 有没有人有什么好的资源或插件可以帮助您?

I tried 2 different JQuery corner-rounding plugins. 我尝试了2个不同的JQuery圆角插件。 This one didn't work in either FF or IE and this one only worked in FF. 这一个在FF或IE中都不起作用,而这个仅在FF中起作用。

However, I found a non-JQuery library that worked perfectly in both, DD_roundies . 但是,我发现一个非jQuery库在DD_roundies中都可以很好地工作。

It's got a lot of limitations... but the Transparent Background Corners plugin might work in your scenario. 它有很多限制...但是“ 透明背景角”插件可能会在您的情况下起作用。

If you can, however, I'd suggest actually doing all the rounding server-side with CSS. 但是,如果可以的话,我建议实际上使用CSS在服务器端进行所有取整。 It's all just divs within divs, with different padding for the corner divs. 都是div内的div,而转角div的填充不同。 It gets rid of the huge performance hit that Safari and IE will take if you have lots of rounding to do, and allows you to have the page still look stylish for your users who don't/can't enable javascript. 如果您有大量舍入操作,它可以消除Safari和IE所带来的巨大性能下降,并允许您为那些未启用/无法启用javascript的用户提供页面外观。

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

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