【问题标题】:Drop down menu inside a Table with Haml带有 Haml 的表格内的下拉菜单
【发布时间】:2013-03-14 07:56:08
【问题描述】:

我需要在 haml 中对表格列内的下拉菜单进行编码,我还不能对其进行测试,但我想确定我是否对我粘贴的以下 sn-ps 代码做得很好。 这只是悬停时的 CSS 下拉菜单

 %thead
     %tr
      %th.date.header
        = "#{t :"date"}"
          %a
            ="#{t :"main_link"}"
          %ul
              %li
                 ="#{t :"link1"}"
              %li
                 ="#{t :"link2"}"
              %li
                 ="#{t :"link3"}"

  %th.header 
    = "#{t :"Sports"}"
  %th.header 
    = "#{t :"Event"}"
  %th.header 
    = "#{t :"Media"}"

我还写了 Css 的样子

.date.header ul { display: none}
.date.header ul:hover {display: block}

这是个好方法吗?如何改进?

【问题讨论】:

  • t 应该是I18n.t 的快捷方式吗?我问是因为= "#{t :"Media"}" 可能会引发错误。

标签: css ruby drop-down-menu haml


【解决方案1】:

我会这样写你的代码

%thead
  %tr
    %th.date.header
      = t('date')
      %a= t('mail_link')
      %ul
        %li= t('link1')
        %li= t('link2')
        %li= t('link3')

    %th.header= t('Sports')
    %th.header= t('Event')
    %th.header= t('Media')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 2012-04-05
    • 1970-01-01
    • 1970-01-01
    • 2019-10-06
    • 2018-01-27
    • 1970-01-01
    • 2018-06-19
    相关资源
    最近更新 更多