1
他のdivが内部にあるdivを作成しようとしました.1つのコンテナdiv、1つ上のdivと1つ下のdivです。私は解決するために助けが必要なCSSの配置に問題があります。問題は、ボトムdivがボトムではなくトップにくっついてしまい、その理由を理解できないことです。jQueryでdivを作成するときにCSSの配置に問題が発生する
JAVASCRIPT(jQueryの):
$('<div/>', {
id: 'window',
width: this.width,
height: this.height,
}).appendTo('#content');
$('<div/>', {
id: 'windowTop',
width: this.width,
height: '30'
}).appendTo('#window');
$('<div/>', {
id: 'windowBottom',
width: this.width,
height: '50',
}).appendTo('#window');
CSS:
#window {
position: relative;
background: red;
margin-left: auto;
margin-right: auto;
}
#windowTop {
position: absolute;
top: 0;
background: yellow;
}
#windowBottom {
positon: absolute;
bottom: 0;
background: green;
}
#windowにテキストを追加しようとしましたが、同じ結果が得られました。/ – holyredbeard
何らかの理由で、今すぐ動作します。ありがとう。 – holyredbeard