zoukankan      html  css  js  c++  java
  • CSS3之圆角

    CSS3圆角border-radius也是比较常用的,有了圆角,可以少很多图片了:)

    语法:

    border-radius : none | <length>{1,4} [/ <length>{1,4} ]?

    说明:length不可为负值。border-radius是一种缩写方法。如果“/”前后的值都存在,那么“/”前面的值设置其水平半径,“/”后面值设置其垂直半径。如果没有“/”,则水平和垂直半径相等。另外其四个值是按照top-left、top-right、bottom-right、bottom-left的顺序来设置的。

    一个简单的例子:

    <!DOCTYPE html>
    <html>
    <head>
    <style> 
    #radius
    {
    text-align:center;
    border:2px solid #a1a1a1;
    padding:10px 40px; 
    background:#dddddd;
    width:350px;
    height:200px;
    border-radius:25px;
    -moz-border-radius:25px; 
    }
    </style>
    </head>
    <body>
    <div id="radius">Border-Radius</div>
    </body>
    </html>
                          

    图:

    设置两个值时,对角的值相同,top-left和bottom-right取第一个值,另外两个角取另一个值。

    <!DOCTYPE html>
    <html>
    <head>
    <style> 
    #radius
    {
    text-align:center;
    border:2px solid #a1a1a1;
    padding:10px 40px; 
    background:#dddddd;
    width:350px;
    height:200px;
    border-radius:25px 50px;
    -moz-border-radius:25px 50px; 
    }
    </style>
    </head>
    <body>
    <div id="radius">Border-Radius</div>
    </body>
    </html>
                          

    效果:

    另外还可以分别设置每个角的水平和垂直半径:

    border-radius:15px 30px / 20px 10px;

    等价于:

    border-top-left-radius:15px 20px;
    border-bottom-right-radius:15px 20px;
    border-top-right-radius:30px 10px;
    border-bottom-left-radius: 30px 10px;

    效果:

    另外,当圆角半径小于等于边框厚度时,内圆角会是方形的,这也很好理解,例如:

    border:20px solid #a1a1a1;
    border-radius:20px;

    效果:

    当圆角半径大于边框厚度时,边框内部也会呈现圆角效果:

    border:10px solid #a1a1a1;
    border-radius:20px;

    效果:

    可以利用圆角绘制圆形:

    <!DOCTYPE html>
    <html>
    <head>
    <style> 
    #radius
    {
    text-align:center;
    margin:50px auto;
    width:0;
    height:0;
    border:100px solid #a1a1a1;
    border-radius:100px;
    }
    </style>
    </head>
    <body>
    <div id="radius"></div>
    </body>
    </html>
                          

    效果:

    还记得那个CSS3的哆啦A梦么?就是用了很多圆角绘制的。

  • 相关阅读:
    我和Socket的第一次亲密接触
    JS获取浏览器高度,JS获取屏幕高度,JS获取宽屏
    GridControl默认不选中任何行样式
    C# Image和Byte[]互相转换
    导出Excel神器最终版
    Log4NET SQL配置
    Log4NET Oracle 配置
    oracle客户端配置
    pgsql环比和同比计算
    02_接管Activiti流程用户及用户组
  • 原文地址:https://www.cnblogs.com/linda586586/p/4206753.html
Copyright © 2011-2022 走看看