【问题标题】:How to transform <a href="#"></a> to <%= link_to %> with css?如何使用 css 将 <a href="#"></a> 转换为 <%= link_to %>?
【发布时间】:2014-07-13 22:50:09
【问题描述】:

如何将 (a href) 转换为 ?

这段代码可以用,但我不需要。

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

我需要使用 来跟踪代码。但我希望样式不会消失。

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

【问题讨论】:

    标签: html css ruby-on-rails


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      更新它:-

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

      【讨论】:

      • 我认为,#mainNav 不适合li 标签。
      猜你喜欢
      • 1970-01-01
      • 2015-10-16
      • 1970-01-01
      • 2021-04-20
      • 1970-01-01
      • 2017-06-13
      • 1970-01-01
      • 2018-11-12
      • 2020-06-17
      相关资源
      最近更新 更多