【问题标题】:Make button active on mobile?在手机上激活按钮?
【发布时间】:2017-04-29 09:41:25
【问题描述】:

当用户点击按钮时...

#featured-challenge-button {
  background-color: #446CB3;
  box-shadow: 3px 3px 5px black;
  &:hover {
    background-color: #ccac00;
    box-shadow: none; 
  }
  &:active {
    background-color: #ccac00;
    box-shadow: none; 
  }
  &:focus {
    background-color: #ccac00;
    box-shadow: none; 
  }
}

按钮示例:

# link_to
<%= link_to next_challenge_path, class: "btn", id: "featured-challenge-button" do %>
  <span class="glyphicon glyphicon-plus"></span>
<% end %>

# submit
<%= button_tag(type: 'submit', class: "btn", id: "featured-challenge-button")  do %>
  Save
<% end %>

如何证明它是立即按下的?

在浏览器上它可以工作,但在我的 iPhone 上,点击按钮后没有效果。点击按钮的唯一指示是屏幕顶部的加载栏。

我使用:active 是错误的还是有其他CSS 技术或有javascript 解决方案?

【问题讨论】:

标签: html css ruby button mobile


【解决方案1】:

您需要在按钮上使用ontouchstart 事件。只需使用

ontouchstart="" 在您的元素上,:active 将起作用。

<button ontouchstart="">An Example</button>

【讨论】:

  • 你知道我如何与 ruby​​ 集成吗?更新的问题。我现在正试图自己弄清楚,但如果你知道的话,我会很感激的:)
  • @AnthonyGalli.com 实际上,您不需要将问题从 html/js 更改为 ruby​​。你必须提出一个新问题。 Ruby 怎么样,抱歉我不知道 Ruby
猜你喜欢
  • 2015-10-14
  • 1970-01-01
  • 1970-01-01
  • 2021-07-30
  • 1970-01-01
  • 1970-01-01
  • 2014-10-11
  • 1970-01-01
  • 2020-01-18
相关资源
最近更新 更多