使用css3画出各种各样的椭圆的原理
我们需要使用css3中的border-radius属性,修改width值为200px,然后把border-radius改成100px / 50px;“/”之前的是水平半径,”/”之后的是垂直半径,所以 100px / 50px就让div成了椭圆border-radius: 100px/50px;
我们既然需要使用css3中的border-radius属性,那么今天我们将带大家详细了解一下border-radius属性。
border-radius属性
含义:border-radius属性简写属性为元素添加圆角边框。
语法:border-radius: 1-4 length|% / 1-4 length|%;
浏览器兼容性:ie9+、firefox 4+、chrome、safari 5+ 以及 opera 支持 border-radius 属性。
使用css3画出各种各样的椭圆的代码
<!doctype html><html><head><meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> <style> #rcorners1 { border-radius: 50px/15px; background: #8ac007; padding: 20px; width: 200px; height: 150px; }#rcorners2{ border-radius: 15px/50px; background: #8ac007; padding: 20px; width: 200px; height: 150px; }#rcorners3 { border-radius: 50%; background: #8ac007; padding: 20px; width: 200px; height: 150px;} </style></head><body>
实例效果如图所示
应用:使用css3画出椭圆后插入图片
<!doctype html> <html> <head> <style> img { border-radius: 50%; } </style> </head> <body> <h2>椭圆形图片</h2> <p>使用 border-radius 属性来创建椭圆形图片:</p> <img src="paris.jpg" alt="paris" width="400" height="300"> </body> </html>
实例效果如图所示
以上就是如何快速简单的使用css3画出各种各样的椭圆的详细内容。