溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

css3怎么繪制半圓

發(fā)布時(shí)間:2021-07-22 09:40:16 來(lái)源:億速云 閱讀:203 作者:chen 欄目:web開(kāi)發(fā)

這篇文章主要介紹“css3怎么繪制半圓”,在日常操作中,相信很多人在css3怎么繪制半圓問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”css3怎么繪制半圓”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

css3繪制半圓的方法:1、利用border-radius屬性實(shí)現(xiàn),只需要將相鄰兩個(gè)角的值設(shè)置為寬/高度的一半,另兩個(gè)角設(shè)置為0即可。2、利用css3的clip屬性和rect()函數(shù)來(lái)實(shí)現(xiàn)。

本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。

方法1:使用border-radius實(shí)現(xiàn)半圓

border-radius屬性用于給元素設(shè)置圓角邊框,可以指定1-4值,為邊框創(chuàng)建(1~4個(gè))圓角效果

語(yǔ)法:

border-radius: 1-4 length|%

每個(gè)半徑的四個(gè)值的順序是:左上角,右上角,右下角,左下角。如果省略左下角,右上角是相同的。如果省略右下角,左上角是相同的。如果省略右上角,左上角是相同的。

示例:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
}

.clearfix {
zoom: 1;
/*為IE6,7的兼容性設(shè)置*/
}

.clearfix:after {
content: '.';
display: block;
height: 0;
clear: both;
visibility: hidden;
}

ul li {
list-style: none;
float: left;
margin: 50px 0 50px 20px;
text-align: center;
}

li {
background: red;
}

h3 {
margin-top: 20px;
}

.circle1 {
width: 100px;
height: 50px;
border-radius: 50px 50px 0 0;
line-height: 50px;
}

.circle2 {
width: 50px;
height: 100px;
border-radius: 0 50px 50px 0;
line-height: 100px;
}

.circle3 {
width: 100px;
height: 50px;
border-radius: 0 0px 50px 50px;
line-height: 50px;
}

.circle4 {
width: 50px;
height: 100px;
border-radius: 50px 0 0 50px;
line-height: 100px;
}

.circle5 {
width: 100px;
height: 100px;
border-radius: 50px;
line-height: 100px;
}

</style>
</head>
<body>
<div>
<h3>用border-radius實(shí)現(xiàn)半圓</h3>
<ul>
<li>上邊圓</li>
<li>左邊圓</li>
<li>下邊圓</li>
<li>左邊圓</li>
<li>全圓</li>
</ul>

</div>
</body>
</html>

效果圖:

css3怎么繪制半圓

方法2:使用css3的clip 方法剪裁實(shí)現(xiàn)半圓

clip 屬性剪裁絕對(duì)定位元素。也就是說(shuō),只有 position:absolute 的時(shí)候才是生效的。唯一合法的形狀值是:rect (top, right, bottom, left)

示例:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>

.clearfix {
zoom: 1;
/*為IE6,7的兼容性設(shè)置*/
}

ul li {
list-style: none;
float: left;
margin: 50px 0 50px 20px;
text-align: center;
}

li {
background: red;
}

h3 {
margin-top: 20px;
}


.demo {
/*左半圓*/
position: absolute;
/*clip 屬性剪裁絕對(duì)定位元素。也就是說(shuō),只有 position:absolute 的時(shí)候才是生效的。*/
width: 100px;
height: 100px;
border-radius: 50px;
/* line-height: 50px; */
clip: rect(0px 50px 100px 0px);
/*唯一合法的形狀值是:rect (top, right, bottom, left)*/
}

.right-circle {
/*右半圓*/
left: 200px;
clip: rect(0px 100px 100px 50px);
/*唯一合法的形狀值是:rect (top, right, bottom, left)*/
}


</style>
</head>
<body>
<div>
<h3>css3的clip 方法剪裁實(shí)現(xiàn)半圓</h3>
<p style="color: red;"></p>
<ul style="position: relative;">
<li>左半圓</li>
<li class="demo right-circle">右半圓</li>
<li></li>
</ul>
</div>
</body>
</html>

效果圖:

css3怎么繪制半圓

到此,關(guān)于“css3怎么繪制半圓”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI