Frage

I use the following view code which I created in MVC5 and I want to change the button style to be like the forum buttons (e.g. ask question button in this stack forum,add button frame color etc),how should I do that? currently its just text that when you hoover it with the mouse you see line under it...

<p>
    @Html.ActionLink("Create New Item", "Create")
</p>
War es hilfreich?

Lösung

You just need css to style a button.

enter image description here

<p>
    @Html.ActionLink("Create New Item", "Create", 
        null, htmlAttributes: new { @class = "mybtn"})
</p>
<style type="text/css">
    a.mybtn {
        background: #777;
        color: #fff;
        display: inline-block;
        padding: 6px 12px 6px 12px;
        text-decoration: none;
    }
</style>

Andere Tipps

Use the overload

@Html.ActionLink("linktext", "action", "controller", routeValues: new { }, htmlAttributes: new { @class="" })

then supply a css class.

Use this:

<button type="submit" class="btn btn-labeled btn-info" onclick="location.href='@Url.Action(" Details ", "Movies
",new { id = item.Id})'" data-toggle="modal tooltip" data-target="" title="Details">
<span class="btn-label">
    <i class="glyphicon glyphicon-comment"></i>
</span>
Details

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top