简体   繁体   English

如何转型 <a href=“#”></a> 到&lt;%= link_to%&gt;与CSS?

[英]How to transform <a href=“#”></a> to <%= link_to %> with css?

How to transform (a href) to <%= link_to %>? 如何将(a href)转换为<%= link_to%>?

This code is work, but I don't need in it. 这段代码是可行的,但我不需要。

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

I need to rails code with <%= link_to %>. 我需要用<%= link_to%>编写代码。 But I want that styles weren't gone. 但是我希望样式没有消失。

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

style 样式

#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))
        )
    }

In order to output in erb exactly what you have in your original html , you could use the following: 为了在erb准确输出原始html ,可以使用以下命令:

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

Update it:- 更新它:-

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

style 样式

#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))
        )
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM