背景图像不显示无重复

时间:2013-08-19 09:58:27

标签: asp.net css

我正在尝试在ValidationSummary div中放置一个小图标(在项目符号列表的左侧)。图像显示,但在我使用时重复:

background:url(Images/exclamation.png);

当我说:

时,图像根本不显示
background:url(Images/exclamation.png) no-repeat 12px 30px;

我在这里缺少什么。

CSS:

 .validationsummary
  {
   background:url(Images/exclamation.png) no-repeat 12px 30px;
   border:1px solid #b08b38;
   width:99%;    
  }
 .validationsummary ul
 {  
  color:#982b12;
  background-color:PeachPuff;
 }
.validationsummary ul li
 {
 padding:2px 0px 0px 15px; 
 font-size:12px;   
 }

ASPX:

<table width="100%">
 <tr>
  <td width="100%">
   <asp:ValidationSummary ID="vs" runat="server" CssClass="validationsummary" 
    DisplayMode="BulletList" />
  </td>
 </tr>
</table>

<table width="100%" cellspacing="10px">        
 <tr>
  <td width="11%" align="left">
   * Surname
  </td>
  <td width="18%" align="left">
   <asp:TextBox ID="txtSurname" runat="server" Width="93%"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"  
     ControlToValidate="txtSurname" SetFocusOnError="true" Text="*" ForeColor="Red"  
     Display="Dynamic" ErrorMessage="Surname Is Required"></asp:RequiredFieldValidator>
  </td>
 </tr>
</table>

4 个答案:

答案 0 :(得分:1)

尝试

.validationsummary
{
   background:url(Images/exclamation.png) no-repeat 0 0;
   border:1px solid #b08b38;
   width:99%;    
}

如果有效,请相应地定位背景。

答案 1 :(得分:0)

背景图像:网址( '图像/ exclamation.png');

background-repeat-x:no-repeat;

background-repeat-y:no-repeat;

答案 2 :(得分:0)

还要定义背景图像的高度

.validationsummary
  {
   background:url(Images/exclamation.png) no-repeat 12px 30px;
   border:1px solid #b08b38;
   width:99%;   

    height: 200px; /* change it with your requirement */


  }

答案 3 :(得分:0)

.validationsummary
{
    background-image: url('Images/exclamation.png);
    background-repeat: no-repeat;
    background-position: left top; 
    background-size: 16px;
    padding-left: 20px; /* Depends on the size of the image - 16px + 4px actual padding to indent the text to the right of the image */
}