我需要创建自己的下拉列表,以便创建具有其他属性的服务器控件。在大多数情况下,一切进展顺利,但我遇到了一个问题。对于下拉箭头,我只是在 CSS 中使用了背景图片。但是,问题是任何超出图像的文本都会覆盖该图像。任何人都对如何将背景图像保持在顶部或隐藏超出图像位置的任何文本有任何想法?到目前为止,这是我的代码:
.tbSearchDefault
{
border-top:1px solid #abadb3;
border-right:1px solid #dbdfe6;
border-bottom:1px solid #e3e9ef;
border-left:1px solid #e2e3ea;
background-image:url('images/ddlMouseOut.gif');
background-repeat:no-repeat;
background-position:right;
cursor:default;
}
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
<tr>
<td>
<asp:TextBox ID="tbSearchName" runat="server"
CssClass="tbSearchDefault" >
</asp:TextBox>
</td>
</tr>
最佳答案
很难准确地说出您需要什么,但我相信您正在寻找 z-index
css
https://developer.mozilla.org/en-US/docs/CSS/Understanding_z-index
这将允许您设置优先堆叠的内容等等。
.tbSearchDefault
{
z-index: 99; // Sets this class to be over any other element unless z -index is higher.
}
关于asp.net - 将 div 背景图像保持在顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16149748/