2017-10-19 6 views
1

もう1人のユーザ(@Simon Zhu)は、CSSを使って「部分的な境界線」を持つサークルを作成できるかどうか尋ねました。円の90度以上。CSSを使ってサークルに「部分的な境界線」を与える方法

を参照してください:How to create partial circle border in CSS

答えはイエスです - どのアークがclip-pathborder-radius::before擬似要素を使用して可能です。

以下の回答を参照してください。

+0

可能な複製(https://stackoverflow.com/questions/13059190/html5-css3-円 - 部分 - 境界) –

答えて

3

あなたがの組み合わせを使用することができます。

  • clip-path: polygon()
  • border-radius
  • ::before擬似要素

あなたが望む任意の部分円の境界線を作成します。

実施例:[部分的なボーダーとHTML5/CSS3サークル]の

body { 
 
width: 420px 
 
} 
 

 
.circle { 
 
position: relative; 
 
float: left; 
 
width: 112px; 
 
height: 112px; 
 
margin: 6px 6px 12px 6px; 
 
padding: 6px; 
 
background-color: rgb(255, 0, 0); 
 
border-radius: 50%; 
 
} 
 

 
.circle::before { 
 
content: ''; 
 
display: block; 
 
position: absolute; 
 
top: 0; 
 
left: 0; 
 
width: 124px; 
 
height: 124px; 
 
background-color: rgb(255, 255, 255); 
 
} 
 

 
.circle::after { 
 
content: ''; 
 
position: absolute; 
 
top: 0; 
 
left: 0; 
 
display: block; 
 
width: 100px; 
 
height: 100px; 
 
margin: 12px; 
 
background-color: rgb(255, 255, 0); 
 
border-radius: 50%; 
 
} 
 

 
.circle:nth-of-type(1)::before { 
 
clip-path: polygon(0% 0%, 100% 0%, 100% 50%, 50% 50%, 50% 100%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(2)::before { 
 
clip-path: polygon(0% 0%, 100% 0%, 100% 30%, 50% 50%, 30% 100%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(3)::before { 
 
clip-path: polygon(0% 0%, 100% 0%, 100% 10%, 50% 50%, 10% 100%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(4)::before { 
 
clip-path: polygon(0% 0%, 50% 0%, 50% 100%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(5)::before { 
 
clip-path: polygon(0% 0%, 30% 0%, 50% 50%, 30% 100%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(6)::before { 
 
clip-path: polygon(0% 0%, 10% 0%, 50% 50%, 10% 100%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(7)::before { 
 
clip-path: polygon(0% 10%, 50% 50%, 0% 90%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(8)::before { 
 
clip-path: polygon(0% 30%, 50% 50%, 0% 70%, 0% 100%); 
 
} 
 

 
.circle:nth-of-type(9)::before { 
 
clip-path: polygon(0% 45%, 50% 50%, 0% 55%, 0% 100%); 
 
}
<div class="circle"></div> 
 
<div class="circle"></div> 
 
<div class="circle"></div> 
 
<div class="circle"></div> 
 
<div class="circle"></div> 
 
<div class="circle"></div> 
 
<div class="circle"></div> 
 
<div class="circle"></div> 
 
<div class="circle"></div>

関連する問題