2016-11-13 11 views
3

は私がDOM構造の下にポップアップで閉じるアイコン(右上)を配置する方法はありますか?

<div class="DIV1"></div> 
<div class="DIV2">Content of the POPUP</div> 

私の出力は次のようにあるべきDOM構造の下で、ポップアップ閉じるアイコンを配置する必要があります。

enter image description here

ポジショニングは、すべての画面のために働く必要があります。このDOM構造の答えを教えてください。

注:ポップアップコンテンツdivとクローズアイコンdivは区切られています。ここで

+0

あなたはそれらのdivを他のdivとラップする必要があります。そして、あなたはCSSでいくつかの配置が必要になります。表示している画像からコードを共有できますか? – caramba

+0

@caramba私は上記のDOM構造のための位置が必要です。 DIV2はDIV1の中にあり、右上に配置するのは簡単です。しかし、それはDIV1の中にはありません。私はそれを試してみると、解像度を変えるとポジションに固執しません。これらの2つのDOMが親DOMでラップされている可能性はありますか?この親にはより多くの子供が含まれています – Kumaravel

+0

https://jsfiddle.net/kumarokm1995/zod4k1k2/1/このjsfiddleを見てください。私はx軸を制御することはできますが、私はy軸を制御することはできません。 x軸でさえもわずかな位置合わせの変化があります – Kumaravel

答えて

1

は片道

.close 
 
{ 
 
    background-color: black; 
 
    position: absolute; 
 
    color: white;   
 
    width: 10px; 
 
    height : 15px; 
 
    padding: 5px 10px 10px; 
 
    left: 77%; 
 
    margin: calc(20% - 35px) 0 0 8%; 
 
    border-radius: 50%; 
 
} 
 

 
.popup 
 
{ 
 
    width: 77%; 
 
    margin: 20% 8%; 
 
    z-index: 99; 
 
    position: absolute; 
 
    padding: 10px; 
 
    background-color : white; 
 
    height : 300px; 
 
    overflow : scroll; 
 
    }
<div class="close">X</div> 
 

 
<div class="popup"> 
 

 
<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br>fgh<br> 
 

 
</div>

+0

素晴らしい答えをありがとう。 – Kumaravel

+0

@Kumaravelあなたは大歓迎です...そして、あなたもupvoteの能力を持っています:) – LGSon

+0

@Kumaravel私はあなたが受け入れを取り除いた理由を尋ねますか? ...もう1つの答えでは、既存の質問の要件で解決できません。既存のDOM_ – LGSon

2

このfiddle

を見ているあなたは、クラス

#wrapper{ 
 
    position: relative; 
 
    margin-top: 1rem; 
 
    padding: 1rem; 
 
    width: 300px; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
} 
 
#close{ 
 
    position: relative; 
 
    width: 20px; 
 
    height: 20px; 
 
    color: red; 
 
    border: 1px solid red; 
 
    border-radius: 10px; 
 
    float: right; 
 
    text-align: center; 
 
    line-height: 1; 
 
} 
 
#content{ 
 
    position: relative; 
 
    background-color: #fff; 
 
    margin-top: 30px; 
 
    border: 2px solid black; 
 
    padding: 1rem; 
 
}
<div id="wrapper"> 
 
    <div id="close">x</div> 
 
    <div id="content"> 
 
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Temporibus molestias saepe mollitia unde sint voluptas nostrum, cumque minima, ea quam maiores cum vitae ipsa hic! Quas nesciunt officiis alias laudantium!</p> 
 
    </div> 
 
</div>
でIDを置き換えることができます

+0

ありがとう@Saif。Works fine.Superb – Kumaravel

関連する問題