2017-07-21 5 views
0

CSSを使用して同じサイズのサークルを2つ作成しました。デスクトップ画面の出力は、コーディングのようにうまくいきます。しかし、私は電話で出力を見ると、円が重なっています。 VWユニットが反応性の高いページデザインに適していると聞きました。だから私はVWユニットを使用しています。他の技術も歓迎されます。vwユニットを使用してCSSで応答円を作成するにはどうすればよいですか?

HTML:

<div class="circle1"> Hello I am a Circle1 </div> 
    <div class="circle2"> Hello I am a Circle2 </div> 

CSS:何をコードに記述すると、正確に何をしたいに依存する

.circle1 
    { 
    width:100px; 
    height: 100px; 
    border-radius: 50%; 
    font-size: 10px; 
    color:#F7FAF7; 
    line-height: 100px; 
    text-align: center; 
    background:#000; 
    position: fixed; 
    top: 0vh; 
    left: 0vw; 
    }  
.circle2 
    { 
    width:100px; 
    height: 100px; 
    border-radius: 50%; 
    font-size: 10px; 
    color:#F7FAF7; 
    line-height: 100px; 
    text-align: center; 
    background:#000; 
    position: fixed; 
    top: 0vh; 
    left: 8vw; 
    } 
+0

はあなたがデスクトップとモバイルの両方で達成しようとするもののスケッチを作ることはできますか? – murb

+0

私はいくつかの距離を離れていくつかの円が必要です。今私は2つのサークルで試しています。 – nawas

+0

は強制的に位置固定ですか? –

答えて

0

この質問は、エンド非常にオープンです。

円の列を探している場合は、おそらくfloatを使用する必要があります。 その行に十分なスペースがない場合、次の行にサークルが移動します。また、重複や縮尺がないため、すべてのデバイスで良好に見えます。

サンプル:

.circle { 
 
    width: 100px; 
 
    height: 100px; 
 
    border-radius: 50%; 
 
    font-size: 10px; 
 
    color: #F7FAF7; 
 
    line-height: 100px; 
 
    text-align: center; 
 
    background: #000; 
 
    float: left; 
 
    margin: 5px; 
 
    padding: 5px; 
 
}
<div class="circle"> Hello I am a Circle1 </div> 
 
<div class="circle"> Hello I am a Circle2 </div> 
 
<div class="circle"> Hello I am a Circle3 </div> 
 
<div class="circle"> Hello I am a Circle4 </div>

あなたはその周りに並ぶ他のすべての円とセンターサークルを探しているなら、多分相対位置が優れています。しかし、これは携帯端末でよく見えるデザインのようなものではありません。

サンプル:

body { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 

 
.main { 
 
    position: relative; 
 
    width: 100px; 
 
    height: 100px; 
 
    border-radius: 50%; 
 
    font-size: 10px; 
 
    color: #F7FAF7; 
 
    line-height: 100px; 
 
    text-align: center; 
 
    background: #abf; 
 
    left: 200px; 
 
    top: 200px; 
 
} 
 

 
.circle { 
 
    position: absolute; 
 
    width: 100px; 
 
    height: 100px; 
 
    border-radius: 50%; 
 
    font-size: 10px; 
 
    color: #F7FAF7; 
 
    line-height: 100px; 
 
    text-align: center; 
 
    background: #456; 
 
} 
 

 
.pos1 { 
 
    top: 120px; 
 
    left: 0px; 
 
} 
 

 
.pos2 { 
 
    top: -120px; 
 
    left: 0px; 
 
} 
 

 
.pos3 { 
 
    top: 0px; 
 
    left: 120px; 
 
} 
 

 
.pos4 { 
 
    top: 0px; 
 
    left: -120px; 
 
}
<div class="main"> 
 
    Main circle 
 
    <div class="circle pos1"> Hello I am a Circle1 </div> 
 
    <div class="circle pos2"> Hello I am a Circle2 </div> 
 
    <div class="circle pos3"> Hello I am a Circle3 </div> 
 
    <div class="circle pos4"> Hello I am a Circle4 </div> 
 
</div>

関連する問題