简体   繁体   中英

2 link_to on the same line?

So i was wondering if this was possible, because from what i've tried and read it seems not. I have two link_to inside a div, and i want them to be on the same line. One link_to has a string like "Time Machine" and the other is just an X icon, to delete something. If we click on "Time Machine" we go to a different view, and if we click on the "X", we just delete that div, but i don't know how to get them in the same row. I've used the class row, inline, block-inline, i also used col-md to give them a fixed space, but nothing.

Thing is the X gets placed below the other link, resulting in some weird format in the web, so i want the X to be on the right of "Time Machine".

在此处输入图像描述

This is my code:

<div class="row">
   <li class="time_machine" data-toggle="tooltip", title="<%= "#{t '.time'} (#{Time.zone.at(current_user.time_machine_now).strftime('%Y-%m-%d %H:%M')})" %>">
      <%= link_to content_tag(:i, nil, class: "fa fa-remove"), '?time_machine_now=' %>
      <%= link_to "#{t '.time'}", time_selector_users_path, 'data-toggle' => "modal", 'data-target' => "#time_selector_modal", "data-backdrop" => "static" %>
   </li>
</div>

Any ideas?

if you are using bootstrap, then you can try this.

<div class="row">
  <li class="time_machine" data-toggle="tooltip", title="<%= "#{t '.time'} (#{Time.zone.at(current_user.time_machine_now).strftime('%Y-%m-%d %H:%M')})" %>">
    <div class="d-flex"> 
      <%= link_to content_tag(:i, nil, class: "fa fa-remove"), '?time_machine_now=' %>
      <%= link_to "#{t '.time'}", time_selector_users_path, 'data-toggle' => "modal", 'data-target' => "#time_selector_modal", "data-backdrop" => "static" %>
    </div>
  </li>
</div>

Thanks. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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