css3实现上下半圆

html-css012

css3实现上下半圆,第1张

border-radius是可以实现上下左右半圆的,但是如果在整圆里放下半圆,在圆里的位置不太好控制,按照上下左右一个一个介绍

看这样很容易就出啦上下半圆了

如果想在一个整圆中分别作出上下半圆不同颜色,而且圆中带字的话,如图:

恐怕上面的办法就不好使了,做这种双色圆的方法如下:

我用四个圆做对比,结果如下:

用CSS代码设定按钮的圆角样式,这个在css3中才能实现,通过使用border-radius来实现这个效果,不过有浏览器的兼容性问题,-moz(例如 -moz-border-radius)用于Firefox;-webkit(例如:-webkit-border-radius)用于Safari和Chrome;border-radius:5px 15px 20px 25px它的意思就是上的圆角5px,右的圆角15px,下的圆角20px,左的圆角25px,通过例子来实际看下:

<div id="round"></div>

#round {

   padding:10pxwidth:300pxheight:50px

   border: 5px solid #dedede

   -moz-border-radius: 15px     /* Gecko browsers */

   -webkit-border-radius: 15px  /* Webkit browsers */

   border-radius:15px           /* W3C syntax */

}

效果如图:

div{

display: inline-block

border:1px solid #6baabb

width:40px

height:40px

float:left

margin:0px 10px

}

a{

display: inline-block

width:40px

height:40px

background: #6baabb

}

.Round{/*圆*/

border-radius:20px

}

.LeftRound{/*左半圆*/

width:20px

border-radius:20px 0px 0px 20px

}

.RightRound{/*右半圆*/

width:20px

border-radius:0px 20px 20px 0px

}

.TopRound{/*上半圆*/

height:20px

border-radius:20px 20px 0px 0px

}

.BottomRound{/*下半圆*/

height:20px

border-radius:0px 0px 20px 20px

}

<div><a class="Round"></a></div> 全圆

<div><a class="LeftRound"></a></div> 左半圆

<div><a class="RightRound"></a></div> 右半圆

<div><a class="TopRound"></a></div> 上半圆

<div><a class="BottomRound"></a></div> 下半圆