<td id="name_3869-0_0" style="position: relative; " colspan="4">
<div style="float:left;width:100%">
<img src="/img/1.gif" align="middle" style="margin-right: 10px;" class="company_symbol" border="0">
<strong style="margin: auto 5px auto auto; ">yyyy</strong>
<a href="#"><span title="xxxx">xxxx</span></a>
<span class="mm_msg_ident"><img onclick="mm_Msg.sel('[1]730228')" src="/view/new_design/img/msg_unchecked.gif" border="0" align="top" alt="Private message to the owner of subdivision" title="Private message to the owner of subdivision"></span>
<span><a href="#" title="Cancel the contract" alt="Cancel the contract" onclick="return contractDestroy(1510428, 'xxxxx')"><img src="/img/smallX.gif" alt="Cancel the contract" border="0" align="top" style="margin-right: 1px"></a></span>
<input type="hidden" name="supplyContractData[selected][]" value="1510428">
</div>
</td>
我需要的是确保两个跨度(一个具有类 mm_msg_ident,另一个紧随其后) 始终位于 div 的右上角。问题是 div 的大小是可变的,并且 必须保持可变。我可以访问 jquery 1.6.4。关于如何设置这些元素的样式以实现该目标,有什么建议吗?
编辑:假设所关注的两个 span 的大小均为 20x20。
最佳答案
设置position: relative;
在 <div>
上并给它上课,例如container
然后在你的CSS中:
.container span {
position: absolute;
top: 0;
right: 0;
}
.mm_msg_ident {
right 20px;
}
关于jquery - 在 div 中定位元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11031568/