简体   繁体   English

CSS div圆角

[英]CSS div rounded corners

I'm attempting to do the following... 我正在尝试做以下事情......

Here's what I've got right now.. but it's not rendering correctly. 这就是我现在所拥有的......但它没有正确渲染。 Does anyone have any idea as to how I'd fix this? 有没有人知道我如何解决这个问题?

CSS CSS

    /* Curved Corners */
    .bl {
background: url(bl.gif) 0 100% no-repeat;
/*background-color:#EFFBEF;*/
width: 700px;
margin-left: auto ;
margin-right: auto ;}
    .br {
background: url(br.gif) 100% 100% no-repeat;
}
    .tl {
background: url(tl.gif) 0 0 no-repeat;
}
    .tr {
background: url(tr.gif) 100% 0 no-repeat;
}
    .clear {font-size: 1px; height: 1px}

HTML HTML

    <div class="bl"><div class="br"><div class="tl"><div class="tr">

        <div id="header">

    </div>

    <div id="footer">

    </div>

        </div></div></div></div>

Instead I suggest you use CSS3, which unlike other methods, does not require extraneous HTML or Javascript markup that notoriously causes any rounded element to 'flash' upon page load. 相反,我建议你使用CSS3,与其他方法不同,它不需要无关的HTML或Javascript标记,众所周知会导致任何圆角元素在页面加载时“闪烁”。

 -webkit-border-radius: 10px;
 -moz-border-radius: 10px;
 -o-border-radius: 10px;
 -ms-border-radius: 10px;
 -khtml-border-radius: 10px;
 border-radius: 10px;

This generator is also helpful: http://borderradius.com/ and there is another one at http://css3generator.com 这个生成器也很有帮助: http//borderradius.com/ ,还有另一个在http://css3generator.com上

In the newest versions of most (if not all) browsers border-radius: 10px; 在大多数(如果不是全部)浏览器的最新版本中, border-radius: 10px; works just fine, and within due time, the browser specific declarations will be obsolete. 工作得很好,并且在适当的时候,浏览器特定的声明将被淘汰。

To make border radius work in IE6, 7 and 8, try ms-border-radius js library , though I have not tested it (and somebody has responded that it does not work.) My personal opinion is that if anybody is still using these browsers, the internet must look like a strange and scary place to them on the daily, and thus, they will not miss their rounded corners. 为了使边界半径在IE6,7和8中工作,尝试使用ms-border-radius js库 ,虽然我还没有测试过(有人回复说它不起作用。)我个人的意见是,如果有人还在使用这些浏览器,互联网必须在日常生活中看起来像一个奇怪而可怕的地方,因此,他们不会错过他们的圆角。

Aside: The method you are trying to use was more applicable when CSS3 was not as widely supported. 旁白:当CSS3没有得到广泛支持时,您尝试使用的方法更适用。 It was created during a strange period of the Internet when the popularity of IE6 drove countless web developers to find highly non-semantic creative solutions to otherwise simple problems. 它是在互联网的一个奇怪时期创建的,当时IE6的普及推动了无数网络开发人员为其他简单问题找到高度非语义的创造性解决方案。 So thank you Internet Explorer for taking a few years off all of our lives and slowing the progression of web design and development. 非常感谢Internet Explorer在我们的生活中度过了几年,并减缓了网页设计和开发的进程。

总有一些曲线 ,如果浏览器支持它,它会使用原生css来提高速度,如果浏览器不支持,则使用javascript。

Can be done easily with jQuery rounded corners rounded_corner 可以使用jQuery圆角round_corner轻松完成

 $(document).ready(function(){
   $("#b1").corner();
 });

You don't need to worry about cross browser issues with jQuery approach. 您无需担心jQuery方法的跨浏览器问题。

A fantastic summary for all major browsers, telling you how to round each corner or all corners: 所有主流浏览器的精彩摘要,告诉您如何围绕每个角落或所有角落:

http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/ http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/

Instead just put this code in the class where you want to have rounded corners .it will definitely work. 相反,只需将此代码放在您想要圆角的类中。它肯定会起作用。

-khtml-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;

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

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