標籤:ges height www size radius class html ack bsp
border-radius是向元素添加圓角邊框
使用方法:
border-radius:10px; /* 所有角都使用半徑為10px的圓角 */
border-radius: 5px 5px 5px 5px; /* 四個半徑值分別是左上方、右上方、右下角和左下角,順時針 */
不要以為border-radius的值只能用px單位,你還可以用百分比或者em,但相容性目前還不太好。
實心上半圓:
方法:把高度(height)設為寬度(width)的一半,並且只設定左上方和右上方的半徑與元素的高度一致(大於也是可以的)。
div{ height:50px;/*是width的一半*/ width:100px; background:#9da; border-radius:50px 50px 0 0;/*半徑至少設定為height的值*/ }
實心圓:
方法:把寬度(width)與高度(height)值設定為一致(也就是正方形),並且四個圓角值都設定為它們值的一半。如下代碼:
div{ height:100px;/*與width設定一致*/ width:100px; background:#9da; border-radius:50px; }
實心下半圓:
方法:把高度(height)設為寬度(width)的一半,並且只設定左下角和右下角的半徑與元素的高度一致(大於也是可以的)。
div.circle2{
height:50px;
width:100px;
background:#9da;
border-radius:0 0 50px 50px;
}
實心左半圓:
方法:把寬度(width)設為高度(height)的一半,並且只設定左上方和左下角的半徑與元素的高度一致(大於也是可以的)。
div.circle2{
height:50px;
width:100px;
background:#9da;
border-radius:50px 0 0 50px;
}
執行個體右半圓:
方法:把寬度(width)設為高度(height)的一半,並且只設定右上方和右下角的半徑與元素的高度一致(大於也是可以的)。
div.circle2{
height:50px;
width:100px;
background:#9da;
border-radius:0 50px 50px 0;
}
代碼示範:
<!doctype html><html><head> <meta charset="utf-8"> <title>border-radius</title> <style type="text/css"> div.circle{ height:50px;/*是width的一半*/ width:100px; background:#9da; border-radius:50px 50px 0 0;/*半徑至少設定為height的值*/ } div.circle1{ height:100px;/*與width設定一致*/ width:100px; background:#9da; border-radius:50px; } div.circle2{ height:50px; width:100px; background:#9da; border-radius:0 0 50px 50px; } div.circle3{ height:100px; width:50px; background:#9da; border-radius:50px 0 0 50px; } div.circle4{ height:100px;
width:50px; background:#9da; border-radius:0px 50px 50px 0px; } </style></head><body><div class="circle"></div><br/><div class="circle1"></div><br><div class="circle2"></div><br><div class="circle3"></div><br><div class="circle4"></div><br></body></html>
轉載:http://www.imooc.com/code/380
CSS3邊框 圓角效果 border-radius