0
我嘗試動態添加子div,它會自動調整其父div,但我的CSS不能正確呈現它們。下面DIVS的動態添加
HTML
<head>
<title>Dealer Services Hub</title>
</head>
<body>
<div id="wrapper">
<div id="header">
</div>
</div>
<div id="body">
<div id = "maindiv">
<div class = 'maindivs'>Sales/Credit</div>
<div class = 'maindivs'>Finance</div>
<div class = 'maindivs'>Compliance/Audit</div>
<div class = 'maindivs'>Admin</div>
<div class = 'maindivs'>Reporting</div>
<div class = 'maindivs'>EOT</div>
<div class = 'maindivs'>Test</div>
</div>
<div id = "sidebardiv">
<div class = 'sidebardivs' div id = 'recentsdiv'><div id = 'recentlinkstitle'>Frequent Views</div></div>
<div class = 'sidebardivs' div id ='dealercommentsdiv'>Dealer Comments</div>
<div class = 'sidebardivs'>Dealers</div>
</div>
</div>
<!--Footer Div-->
<div id="footer">
<div>
<span>USBNet</span>
</div>
<div>
<span>Best In Us</span>
</div>
<div>
<span>Directory</span>
</div>
</div>
</div>
</body>
CSS
body{
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
#body{
width: 100%;
height: 100%;
float: left;
color:#0C2074;
}
h2{
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}
#wrapper {
width:1400px;
margin: 0;
padding: 0;
height: 100%;
overflow:auto;
}
#header{
width: 1320px;
height: 100px;
float: left;
background: #0C2074;
margin: 0 auto;
}
#maindiv{
width:1000px;
height:100%;
float: left;
color:#0C2074;
overflow:hidden;
}
.maindivs{
width:300px;
height: 220px;
background: #67B2E8;
box-shadow: 10px 10px 8px #888888;
text-align: center;
float: left;
margin-top: 20px;
margin-left: 20px;
cursor:pointer;
border-radius: 10px;
color:#0C2074;
}
#sidebardiv{
width:300px;
height:100%;
float: left;
border-left: 1px solid #5a5a5a;
overflow:hidden;
}
.sidebardivs{
width:90%;
height: 220px;
border: 1px solid #000000;
background: #e5e5e5;
color:#0C2074;
margin-top: 20px;
margin-left: 20px;
border-radius: 10px;
}
#recentsdiv{
font-size: 95%;
}
#dealercommentsdiv{
text-align: center;
float: left;
margin-bottom: 20px;
cursor:pointer;
}
#footer{
width: 1320px;
height:40px;
float: left;
background: #0C2074;
clear: both;
color:#FFF;
}
#footer div{
width:33.33%;
height: 100%;
text-align: center;
float: left;
margin: auto;
padding-top: 5px;
padding-right: 5px;;
padding-bottom: 5px;
padding-left: 5px;
border-left: 1px solid #67B2E8;
border-right: 1px solid #67B2E8;
font-size: 120%;
box-sizing: border-box;
}
額外的div被父 'maindiv' 和 '經銷商' 父 'sidediv' 測試「的結果是代碼」測試'div似乎被切斷在其基地和'經銷商'div之間的空間是多餘的必要
我看不出有什麼動態關於這一點。你也不能重複ID - 它們必須是唯一的 – j08691
我提到動態因爲這是我正在構建的ASP項目的基礎。該div是基於數據庫結構構建的 –