ほとんどのブラウザ(IE、Mozilla、Safari)で動作するcssのみを使用して円を描くことは可能ですか?
356364 次
6 に答える
227
はい、ボックスを描画し、ボックスの幅の半分の境界半径を指定します。
#circle {
background: #f00;
width: 200px;
height: 200px;
border-radius: 50%;
}
作業デモ:
#circle {
background: #f00;
width: 200px;
height: 200px;
border-radius: 50%;
}
<div id="circle"></div>
于 2011-08-04T06:20:52.650 に答える
176
円のユニコード記号(25CF)を含むコンテンツで.beforeを使用できます。
.circle:before {
content: ' \25CF';
font-size: 200px;
}
<span class="circle"></span>
IE8以下ではborder-radiusが機能しないため、これを提案します(提案が少し精神的であるという事実を認識しています)。
于 2011-08-04T06:22:20.110 に答える
51
- 高さと幅が設定された div を作成し (円の場合は、同じ高さと幅を使用します)、正方形を形成します。
- 50%を追加する
border-radius
と、円形になります。(注: プレフィックスは長い間必要ありません) - 次に、
background-color
/ グラデーション / (でもpseudo elements
) をいじって、次のようなものを作成できます。
.red {
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
.sphere {
height: 200px;
width: 200px;
border-radius: 50%;
text-align: center;
vertical-align: middle;
font-size: 500%;
position: relative;
box-shadow: inset -10px -10px 100px #000, 10px 10px 20px black, inset 0px 0px 10px black;
display: inline-block;
margin: 5%;
}
.sphere::after {
background-color: rgba(255, 255, 255, 0.3);
content: '';
height: 45%;
width: 12%;
position: absolute;
top: 4%;
left: 15%;
border-radius: 50%;
transform: rotate(40deg);
}
<div class="sphere red"></div>
<div class="sphere green"></div>
<div class="sphere blue"></div>
<div class="sphere yellow"></div>
<div class="sphere"></div>
于 2015-01-05T09:43:26.077 に答える
11
これはすべてのブラウザで機能します
#circle {
background: #f00;
width: 200px;
height: 200px;
border-radius: 50%;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
}
于 2014-05-20T11:20:59.240 に答える
9
うん..これが私のコードです:
<style>
.circle{
width: 100px;
height: 100px;
border-radius: 50%;
background-color: blue
}
</style>
<div class="circle">
</div>
于 2013-01-29T05:07:46.560 に答える