div
の要素が配置されている場合には、自動的に配置することは可能ですか?absolut
?絶対配置された要素を自動的に配置することはできますか?
コードスニペットには、3つのdiv
要素があり、それらの間に配置されています。 #elem2
と#elem3
のCSSスタイルの指示を削除して、div
要素の間にマージンを入れて配置する必要があるという一般的なルールを構成することは、どういうわけか可能ですか? 10px
?だから私は簡単に新しいdiv
要素(可変高さ)をCSSクラスcolumn1
と追加することができ、それぞれmargin-top
とmargin-bottom
を心配する必要はありません。
#containerGraph {
position: relative;
width: 700px;
height: 400px;
border: 1px solid black;
overflow:scroll;
}
/* set the position attribute for all div elements inside the mainContainer*/
#containerGraph > div {
position: absolute;
}
.paramElement {
width: 200px;
max-height: 90px;
border-radius: 18px;
text-align: center;
background-color: #e6e6e6;
color: #4d4d4d;
font-family: Verdana, Helvetica, sans-serif;
padding-bottom:5px;
font-size: small;
}
.column1{
margin-left:10px;
}
#elem2{
margin-top : 40px;
}
#elem3{
margin-top : 117px;
}
<div id="containerGraph" class="relative">
<div class="paramElement column1" id="elem1">
first
</div>
<div class="paramElement column1" id="elem2">
second with very large text text text text text text text text text text text text text
</div>
<div class="paramElement column1" id="elem3">
third
</div>
</div>