2012-01-12 70 views
2

我想在div标签内制作圆角框。我怎样才能做到这一点?你能举个例子吗?如何使用jquery在DIV标签内制作圆角框?

+0

的可能重复[什么是最好的方法来创建圆角添加到您的网页jquery.corner.js使用CSS?](http://stackoverflow.com/questions/7089/what-is-the-best-way-to-create-round-corners-using-css) – 2012-01-12 07:56:18

回答

7

您可以使用CSS:

.rounded-corners { 
    -moz-border-radius: 20px; 
    -webkit-border-radius: 20px; 
    -khtml-border-radius: 20px; 
    border-radius: 20px; 
} 

然后使用类 “.rounded来访者” 添加到您的div的jQuery:

$("#div-id").addClass("rounded-corners"); 
+4

'border-radius'和'box-阴影“不再需要供应商前缀。请参阅:[MDN浏览器兼容性表格](https://developer.mozilla.org/en/CSS/border-radius#Browser_compatibility) – 2012-01-12 07:37:39

2

我相信你正在寻找border-radius CSS property。 JavaScript与元素的外观无关,只是它们如何行事。

<div style="border-radius:10px;height:100px;width:100px;"></div> 
1

下面是一些浏览器的安全方式:

.box { 
-webkit-border-radius: 6px; 
-moz-border-radius: 6px; 
border-radius: 6px; 
} 
1

你可以在div标签使用JQuery.Corner.Js make的角落。

在第一步后“的jquery.js”

<script src="../JQuery/external/jquery/jquery.js"></script> 
<script src="jquery.corner.js"></script> 

<script> 
    $(document).ready(function() { 

     $("#Div1").corner(); 
     $("#Div2").corner("long"); 
    });  
</script> 


<body> 

    <div id="Div1" style="background-color: blue; 
     width: 150px; height: 150px;"> 
    </div> 
    <br /> 
    <div id="Div2" style="background-color: blue; 
     width: 150px; height: 150px;"> 
    </div> 
    <br /> 
</body> 

你可以在这个地址找到更多的样本JQuery Corner Demo