将div背景图片放在顶部
我需要创建自己的下拉列表,以便可以使用其他属性创建服务器控件。大多数情况下,这一切进展顺利,但我遇到了一个问题。对于下拉箭头,我只是在CSS中使用背景图像。但问题是,任何延伸过图像的文本都会覆盖该图像。任何人都有关于如何将背景图像保留在顶部或隐藏超出图像位置的任何文本的任何想法?这里是我的代码,到目前为止:将div背景图片放在顶部
.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>
好吧,似乎没有办法做到这一点。实际上,我猜背景图像是背景。我最终做的只是在文本框旁边添加一个div,并在那里添加图像。
很难正是你需要有什么说什么,但是我相信你正在寻找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.
}
我想过使用z-index,但是如何为文本框中的背景图像设置z-index? – jason 2013-04-22 14:47:03
您将该类设置为高z-索引,我想我将不得不看到您正在尝试做什么以给出更精确的解决方案的示例。 – 2013-04-22 17:24:47
我想也许你想要这样的东西:http://stackoverflow.com/questions/611482/change-color-and-appearance-of-drop-down-arrow – 2013-04-22 17:36:31
您是否尝试过使用'z-index'? https://developer.mozilla.org/en-US/docs/CSS/Understanding_z-index – 2013-04-22 14:36:06
你有没有尝试将'z-index'属性设置为2? – Niro 2013-04-22 14:36:15
或者你可以给你的文本框填充相同数量的背景图片宽度为 – Morpheus 2013-04-22 14:44:54