Mel Mel - 2 months ago 5
CSS Question

Rails 4 - how to write a link in Rails whilst preserving html styling

I'm trying to adapt a wrap bootstrap theme for use in Rails 4.

The theme styling (which I want to keep has:

<li class='col-xs-4 col-sm-2 nopadding menuitem' style='background:#006F7F'>
<a href='#dash' class='hvr-sweep-to-bottom'>

When I try to write this in rails, I write:

<li class='col-xs-6 col-sm-3 nopadding menuitem' style='background:#39AFBF', class: 'hvr-sweep-to-bottom' >
<%= link_to "Dashboard", '#dash', class: 'span' %>

The problem is, the wrap bootstrap theme has the styling I want to apply in the 'span' class.

The formulation I've tried to use in rails isn't accessing it. When I save this and try inspecting the code in home, the elements applying the link are:

navigation .menuitem a

When I use the html from the wrap bootstrap theme, the chrome inspector shows:

navigation .menuitem a span

How can I get the span into the link text?

<li class='col-xs-6 col-sm-3 nopadding menuitem' style='background: #39AFBF', class: 'hvr-sweep-to-bottom' >
  <%= link_to '#dash', class: 'span' do %>
  <% end %>

Can I make a few suggestions though? I'll do them anyway.

  1. Don't use inline CSS, that's just bad practice and bad code.
  2. Don't use <br> to create a new line, use CSS instead and add margin-top: 20px or something to your a.span element.
  3. Unless you're doing some JavaScript manipulation on your span element, there's no point wrapping Dashboard into a span .