Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 保持div背景图像在顶部_Asp.net_Html_Css_Stylesheet - Fatal编程技术网

Asp.net 保持div背景图像在顶部

Asp.net 保持div背景图像在顶部,asp.net,html,css,stylesheet,Asp.net,Html,Css,Stylesheet,我需要创建自己的dropdownlist,以便创建具有其他属性的服务器控件。在大多数情况下,进展顺利,但我遇到了一个问题。对于下拉箭头,我只使用CSS中的背景图像。但问题是,任何延伸过图像的文本都会覆盖该图像。有人对如何保持背景图像在顶部或隐藏超出图像位置的文本有什么想法吗?以下是我的代码,到目前为止: .tbSearchDefault { border-top:1px solid #abadb3; border-right:1px solid #dbdfe6;

我需要创建自己的dropdownlist,以便创建具有其他属性的服务器控件。在大多数情况下,进展顺利,但我遇到了一个问题。对于下拉箭头,我只使用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>              
.tbSearchDefault
{
边框顶部:1px实心#abadb3;
右边框:1px实心#dbdfe6;
边框底部:1px实心#e3e9ef;
左边框:1px实心#e2e3ea;
背景图像:url('images/ddlMouseOut.gif');
背景重复:无重复;
背景位置:右;
游标:默认值;
}

很难说您需要什么,但是我相信您正在寻找
z-index
css

这将允许您先设置堆栈,以此类推

.tbSearchDefault
{
    z-index: 99; // Sets this class to be over any other element unless z -index is higher.
}

嗯,似乎没有办法做到这一点。我猜背景图像实际上就是背景。我最后做的就是在文本框旁边添加一个div,然后在那里添加图像

您是否尝试过使用
z-index
?您是否尝试将
z-index
属性设置为2?或者,您可以将文本框的填充量设置为与背景图像宽度相同的大小。您可以创建一个简化的文本框吗?我将在哪里设置z-index?我不相信背景图像支持z-indexi使用z-index的想法,但是如何在文本框中为背景图像设置z-index?如果将类设置为高z-index,我想我必须看到一个示例,说明您正在尝试做什么,以提供更精确的解决方案。我想也许您希望这样: