Reputation: 21609
Here's a piece of my HTML code
<div id = "mydiv">
<% = Html.ActionLink("Some Text","SomeAction")%>
</div>
I'd like to style it in white so that it doesn't conflict with the background, which is also blue. So I did this:
#mydiv {background-color:blue;}
#mydiv a:link { color:white}
But, it doesn't work -- the color it's still blue. How can I do it? Maybe, I just did not write well the selectors.
Thanks for helping.
Upvotes: 10
Views: 32812
Reputation: 6613
In my case this one worked
HTML.ActionLink("LinkLabel", "ActionName", "Controller", null,
new {@class="btn btn-primary pull-right"})
If I don't use null above the proper controller action i.e. Controller.ActionName method was not called. Instead something like currentController/Length==4 something like this was called.
Upvotes: 5
Reputation: 2788
Mine is like Luke's but I have a null in there (I'm using MVC2)
<%=Html.ActionLink("Text","Act","Ctrl",new {@style="color:white;"}) %>
Upvotes: 5
Reputation: 84724
Remove the :link
suffix and you should be fine:
#mydiv { background-color:blue; }
#mydiv a { color:white; }
Alternatively you can add a class name to the link:
<div id="mydiv">
<%= Html.ActionLink("Some Text", "SomeAction",
new { @class = "class-name" }) %>
</div>
Upvotes: 10
Reputation: 245
Maybe
<%=Html.ActionLink("Text","Act","Ctrl",new {@style="color:white;"}) %>
Upvotes: 9
Reputation: 14229
Try:
#mydiv a { color:white}
Also, try remove the whitespace around your Id attribute (just in case): ->
Upvotes: 1
Reputation: 36071
Try removing the :link and just having
#mydiv a { color:white}
this should colour the link white.
I'd recommend using the Firebug plugin for firefox also, this allows you to change the stylesheet and see instant changes as well as see which styles are being applied to each element, which styles are being 'overuled' by other styles etc.
Upvotes: 2