CSS3边框与圆角

html-css022

CSS3边框与圆角,第1张

属性:一个最多可指定四个border-*-radius属性的 符合属性 ,这个属性允许你为元素添加圆角边框!

语法:border-radius:1-4 length|% / 1-4length|%

【length可为任意长度单位,比如px、em。

当使用%的时候,相对的不是字体的大小而是对应边的长度的百分比,例如border-top-left-radius:50%,那么左上角的圆角在左边的弧度是边框左边长度的50%、在上边的弧度是边框上边长度的50%;

因此如果设置border-radius:50%,那么边框将会变为一个椭圆】

兼容性:IE9+、Firefox4+,Chrome,Safari5+,Opera

-------------------------------------------------

CSS3指定每个圆角:

多值:

border-radius(四个值):左上角 右上角 右下角 左下角

border-radius(三个值):左上角 右上角和左下角 右下角

border-radius(两个值):左上角和右下角 右上角和左下角

border-radius(一个值):四个圆角值相同

border-top-left-radius:定义了左上角的弧度

border-top-right-radius:定义了右上角的弧度

border-bottom-left-radius:定义了右下角的弧度

border-bottom-right-radius:定义了左下角的弧度

box-shadow属性:可以设置一个或多个下拉阴影的框

语法:

box-shadow:h-shadow(水平位置偏移量)允许负值。必写;

v-shadow(处置位置偏移量)允许负值。必写;

blur(模糊距离)可选;

spread(阴影尺寸)可选;

color(阴影颜色)可选;

inset(内部阴影)可选;扩展属性,正值缩小,负值增大

box-shadow: 10px(横向,正值往右,负值往左) 10px(纵向,正值往下,负值网上) 10px(模糊,从边框到内容,完成渐变模糊) 10px(扩展,四周边界往外扩展10px) yellow(阴影颜色)

border-image

属性:使用border-image-*属性来构建美丽的可扩展按钮

语法:border-image:source slice width outset repeat;

兼容性:IE不兼容、Firefox、Chrome、Safari6+、Opera不兼容

-------------------------------------------------

border-image-source属性

border-image-source属性指定要使用的图像,而不是由border-style属性设置的边框样式

语法

border-image-source:none;

border-image-source:url("...");

-------------------------------------------------

border-image-slice属性

border-image-slice属性指定图像的边界向内偏移

语法

border-image-slice:number|%|fill;

-------------------------------------------------

border-image-width属性

brder-image-width属性指定图像边界的宽度

语法

border-image-width:number|%|auto;

-------------------------------------------------

border-image-outset属性

border-image-outset用于指定在边框外部绘制border-image-area的量

语法

border-image-outset:length|number;

-------------------------------------------------

border-image-repeat属性

该属性用于图像边界是否重复(repeated)、拉伸(stretched)或铺满(rounded)

语法:border-image-repeat:stretch|repeat|round|initial|inherit;

直接用css属性值设置边线:border即可,还可以单独设置border-left,right,bottom,top。

用ccs3中的盒阴影设置,是一种固定写法: box-shadow:1px 1px red,inset 1px 1px red.

你好,我这里用CSS实现了三种带边框三角,效果分别如图:

实例代码如下,根据你个人的情况调整代码吧:

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Arrow</title>

</head>

<body>

<style>

/* scale */

.arrow,

.arrow:after{

    position: relative

    display: inline-block

    width: 0

    height: 0

    border-top: 0

    border-left: 30px dotted transparent

    border-right: 30px dotted transparent

    border-bottom: 30px dashed #000

}

.arrow:after {

    position: absolute

    top: 0

    content: ''

    transform: translateX(-50%) scale(.8)

    border-bottom: 30px dashed #fff

}

/* width & height */

.arrow1,

.arrow1:after {

    position: relative

    display: inline-block

    width: 0

    height: 0

    border-top: 0

    border-left: 30px dotted transparent

    border-right: 30px dotted transparent

    border-bottom: 30px dashed #000

}

.arrow1:after {

    position: absolute

    left: -26px 

    top: 2px

    content: ''

    width: 0 

    height: 0 

    border-top: 0 

    border-left: 26px dotted transparent 

    border-right: 26px dotted transparent 

    border-bottom: 26px dashed #fff

}

/* border & after */

.arrow2 {

    position: relative

    display: inline-block

    width: 28px

    height: 28px

    border: 0

    border-top: 2px solid #000

    border-right: 2px solid #000

    -webkit-transform: translate(7px, 14px) rotate(-45deg)

    -ms-transform: translate(7px, 14px) rotate(-45deg)

    -o-transform: translate(7px, 14px) rotate(-45deg)

    transform: translate(7px, 14px) rotate(-45deg)

}

.arrow2:after {

    position: absolute

    left: 0

    top: -2px

    width: 42px

    height: 2px

    content: ''

    border-radius: 2px

    background-color: #000

    -webkit-transform-origin: left top

    -moz-transform-origin: left top

    -ms-transform-origin: left top

    -o-transform-origin: left top

    transform-origin: left top

    -webkit-transform: rotate(45deg)

    -ms-transform: rotate(45deg)

    -o-transform: rotate(45deg)

    transform: rotate(45deg)

}

</style>

<span class="arrow"></span>

<span class="arrow1"></span>

<span class="arrow2"></span>

</body>

</html>

希望能帮到你,如有疑问请追问,望采纳~