2013-08-19 219 views
0

我試圖在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> 
+0

只需使用「background-repeat:none;」低於「背景」。 – Robert

+1

您是否嘗試過沒有定位屬性的「不重複」?您可能會將其移出屏幕。 – James

+0

另外,屏幕上的驗證總結有多大? –

回答

0

背景圖像:網址( '圖像/ exclamation.png');

background-repeat-x:no-repeat;

background-repeat-y:no-repeat;

+0

該屬性不可用。你是指背景重複:repeat-x no-repeat;那也行不通 – Ruby

0

還要定義背景圖片的高度

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

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


    } 
1

嘗試

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

如果是工作,因此定位你的背景。

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 */ 
}