javascript - 跨浏览器的弧形边框

标签 javascript html css

在 div 上实现跨浏览器(ff,ie> 6,chrome,opera,safari) flex Angular 的最佳方法是什么。我找到了这篇文章 http://jonraasch.com/blog/css-rounded-corners-in-all-browsers我已经多次按照说明一步步进行,这是我的 CSS:

#content_wrapper{
    -moz-border-radius:25px 25px 25px 25px;
    -webkit-border-radius: 25px;
    -khtml-border-radius: 25px;
    border-radius: 25px;
    background-color:#F2DADC;
    border:25px solid #ECD3D5;
    height:780px;
    opacity:0.7;
    width:747px;
    margin:0px auto;
    position:relative;
    display:block;
    zoom:1;
}

<!--[if lte IE 8]>
<style>
#content_wrapper{
behavior: url(template/css/border-radius.htc);
border-radius: 20px;
}
</style>
<![endif]-->

有人能指出我做错了什么吗,或者有没有更好的方法来实现同样的效果,它在除 IE 之外的所有浏览器中都可以工作

最佳答案

如果这是来自您的 HTML 文件的未经修改的片段,那么它不起作用的原因很明显:您正在使用 <style>另一个标签 <style> .

作为第一个测试,只需尝试将整个代码段替换为(删除 IE 特定 block !):

#content_wrapper{
    -moz-border-radius:25px 25px 25px 25px;
    -webkit-border-radius: 25px;
    -khtml-border-radius: 25px;
    behavior: url(template/css/border-radius.htc);
    border-radius: 25px;
    background-color:#F2DADC;
    border:25px solid #ECD3D5;
    height:780px;
    opacity:0.7;
    width:747px;
    margin:0px auto;
    position:relative;
    display:block;
    zoom:1;
}

如果可行,您可以将 IE 特定部分移动到单独的 <style> 中:

<style type="text/css">
#content_wrapper{
    -moz-border-radius:25px 25px 25px 25px;
    -webkit-border-radius: 25px;
    -khtml-border-radius: 25px;
    border-radius: 25px;
    background-color:#F2DADC;
    border:25px solid #ECD3D5;
    height:780px;
    opacity:0.7;
    width:747px;
    margin:0px auto;
    position:relative;
    display:block;
    zoom:1;
}
</style>


<!--[if lte IE 8]>
<style type="text/css">
#content_wrapper{
    behavior: url(template/css/border-radius.htc);
    border-radius: 20px;
}
</style>
<![endif]-->

如果您仍然遇到问题,请尝试来自 google 网站的示例 zip 文件:http://code.google.com/p/curved-corner/downloads/detail?name=border-radius-demo.zip

关于javascript - 跨浏览器的弧形边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2795097/

相关文章:

html - 图形和重叠段落中的可点击图像

asp.net - 弹出窗口,如何在IE8中隐藏地址栏

javascript - 是否可以使用 jquery 更新 html 表中每个复选框的名称

html - CSS 列标题

html - 具有动态内容的固定宽度侧边栏

javascript - Tab 焦点到 JavaScript 中的单选按钮

javascript - 关闭(忽略)html 文本/搜索元素中的占位符属性

javascript - Promise resolve 在 TypeScript 中有错误,因为错过了任何类型

javascript - 将 table、tr、td 标签附加到 innerHTML 不会创建表格行

javascript - 有没有更好的方法来编写这个 jQuery 脚本?