我有一個下拉列表,它將動態添加div類中的圖像元素,類名爲DrugNameCard
,id爲testDiv
。通過下面的所有嘗試,HTML不會偵聽CSS。我在這裏錯過了什麼?在div中動態添加圖片
CSS - 各種失敗嘗試
body {
}.DrugNameCard
{
height:3.85in;
width: 2.625in;
border: 5px solid black;
padding-right:.25in;
padding-left:.25in;
padding-top:.25in;
}
img div.DrugNameCard
{
height:.64in;
width: .64in;
padding-left: .1in;
}
img > div.DrugNameCard
{
height:.64in;
width: .64in;
padding-left: .1in;
}
img > .DrugNameCard
{
height:.64in;
width: .64in;
padding-left: .1in;
}
img .DrugNameCard
{
height:.64in;
width: .64in;
padding-left: .1in;
}
img #testDiv
{
height:.64in;
width: .64in;
padding-left: .1in;
}
HTML
<select name="DropDownList2" onchange="javascript:setTimeout('__doPostBack(\'DropDownList2\',\'\')', 0)" id="DropDownList2">
<option selected="selected" value="-1">Select picture to add</option>
<option value="Images/bandAid.jpg">BandAid</option>
<option value="Images/Confusion.jpg">Confusion</option>
<option value="Images/sadFace.jpg">Depression</option>
<option value="Images/sleepiness.jpg">Sleepiness</option>
</select>
<br />
<div id="testDiv" class="DrugNameCard">
<img src="Images/Confusion.jpg" /><img src="Images/sleepiness.jpg" /><img src="Images/sadFace.jpg" /></div>
<input type="submit" name="btnSubMitDrugName" value="Submit Drug Name" id="btnSubMitDrugName" />
我會建議在jsfiddle或類似的例子。 –
@ Ek0nomik我正在使用C#來做到這一點,我不認爲我可以展示什麼比我在這裏與小提琴更多。 – wootscootinboogie