0

我正在尝试创建购物清单。该列表是使用 Javascript (jQueryUI) 动态创建的。我希望旁边的垃圾桶在右侧(我画的这个蓝点在哪里)。我尝试使用leftorstyle="right:350px"float:rightin 标签来做到这一点,但它没有用。

在此处输入图像描述

这是我生成行的代码:

var row=$('<div class"productsclass" id='+selectedproducts[i]+' style="width:400px">
<label style="font-size:20px">'+selectedproducts[i]+'</label><input type="text" 
name="Quantity" value="1" id='+thesi+'><img class=delete 
src="http://b.dryicons.com/images/icon_sets/handy_part_2_icons/png/128x128/recycle_bin.png"
 height="22" width="22" style="right:350px"></div>'); 
   rowID++;

   $("#productstable").append(row);

这是html:

<div id="maindiv" class="maindiv">
<input id="autocomplete_text_field">
<button id="add_product_button">Add product</button>
<form action="#" id="productstable" name="productstable">
<p></p>
</form>
</div>
</body>

这是CSS:

#body{
    background-color: #6E0D25
}

#maindiv {
    position:absolute;
    top: 50%;
    left: 50%;
    width:30em;
    height:18em;
    margin-top: -9em; /*set to a negative number 1/2 of your height*/
    margin-left: -15em; /*set to a negative number 1/2 of your width*/
    /*border: 1px solid #ccc;*/
    background-color: #6E0D25;
}

#productstable
{
    background-color:#F1EBE4;
    border-radius:10px;
    width:400px;
}

#product
{
    width:380px;
}
#autocomplete_text_field
{
    width:200px;
    height:40px;
    border-radius:10px;

}

#add_product_button
{
    width:200px;
    height:50px;
    border-radius:10px;
}

我该怎么做?(对不起,如果这是一个非常无用的问题,这几乎是我第一次使用CSS)

在 user2313440 的回答后解决:

在此处输入图像描述

4

2 回答 2

0

更改img class=delete为然后在 CSS 中img class="delete"添加到它。float:right;

于 2013-04-29T19:20:09.017 回答
0

只需简单地重新排列您的 img,并使用 float:right;

试试这个代码:

var row=$('    <div class "productsclass" id='+selectedproducts[i]+' style="width:400px">
    <img class=deletesrc="http://b.dryicons.com/images/icon_sets/handy_part_2_icons/png/128x128/recycle_bin.png" height="22" width="22" style="float: right;">
<label style="font-size:20px">'+selectedproducts[i]+'</label>
<input type="text" name="Quantity" value="1" id='+thesi+'>
</div>'); 

rowID++;

 $("#productstable").append(row);
于 2013-04-29T19:20:58.083 回答