如何将<a href="#"></a>转换为&lt;%= link_to%&gt;用css?

时间:2014-05-24 18:45:44

标签: html css ruby-on-rails

如何将(a href)转换为&lt;%= link_to%&gt;?

此代码可以使用,但我不需要它。

<li><a href="users"><span>User</span></a></li>

我需要使用&lt;%= link_to%&gt;来修改代码。但我希望这些风格没有消失。

<li><%= link_to user_path %></li>

#mainNav a:active{
        top:1px;
    }
    #mainNav a:hover span ,
    #mainNav li.active span {
        background-image: linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -o-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -moz-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -webkit-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -ms-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);

        background-image: -webkit-gradient(
            linear,
            left bottom,
            left top,
            color-stop(0, rgb(71,83,101)),
            color-stop(1, rgb(123,145,177))
        )
    }

2 个答案:

答案 0 :(得分:1)

为了在erb中准确输出原始html中的内容,您可以使用以下内容:

<li>
  <%= link_to user_path do %>
    <span>User</span>
  <% end %> 
</li>

答案 1 :(得分:0)

更新它: -

<li id="mainNav"><%= link_to "Users", users_path %></li>

<强>式

#mainNav a:active{
        top:1px;
    }
    #mainNav a:hover ,
    #mainNav li.active {
        background-image: linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -o-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -moz-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -webkit-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);
        background-image: -ms-linear-gradient(bottom, rgb(71,83,101) 0%, rgb(123,145,177) 100%);

        background-image: -webkit-gradient(
            linear,
            left bottom,
            left top,
            color-stop(0, rgb(71,83,101)),
            color-stop(1, rgb(123,145,177))
        )
    }