1

asp:Button will not be styled with css.

CSS:

.TabButton
{
    border: none;
    background-size: cover;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
}

HTML5:

<asp:Button runat="server" Text="Events" CssClass ="TabButton" OnClick ="NavigationTab_OnClick" style="background-image:url(image link)"/>

This doesn't work. The css code has no effect on the button. I have tried changing the "CssClass" property to just "class". Still nothing. I have also tried "id". I can style other elements using the same .css file.

5
  • have you checked in firebug weather the rule is applied to the button or not? Commented Oct 5, 2013 at 8:09
  • It takes effect in the "design" view of visual studio 2012, but not when I run the project in chrome... Commented Oct 5, 2013 at 8:29
  • do you have problem with other browsers or just chrome ?just for test change your css class to something like width:200px; to see whether it take affect or not. Commented Oct 5, 2013 at 9:11
  • Hmmm. Okay, it works in IE, but not chrome. Commented Oct 5, 2013 at 9:29
  • Cleared the browsing cache and now it works. VS2012 for web is pretty buggy. Commented Oct 5, 2013 at 9:36

1 Answer 1

0

You have to define inline style for image like that:

style="background-image:url('image link')"

and maybe you are missing something, that's why that class you applied not working well. Maybe some minor detail mis-matching. Otherwise it's correct.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.