- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如何使下面的单选按钮看起来像按钮?
<%= simple_form_for(@challenge) do |f| %>
<%= f.text_field :action, placeholder: 'Enter a Custom Challenge' %>
Or choose a featured challenge:
<%= f.input :action, collection: ['Lose 10 Pounds', 'Exercise'], as: :radio_buttons %>
<% end %>
现在我让它看起来像一个按钮,但我无法让它工作。例如,当我单击该框时,背景不会变成黄色并且 radio [input] 不会被选中。
换句话说,我想要这个:
http://jsfiddle.net/YB8UW/654/
像这样工作:
.challenge_action {
list-style-type:none;
margin:25px 0 0 0;
padding:0;
}
.challenge_action span {
float:left;
margin:0 5px 0 0;
width:100px;
height:40px;
position:relative;
}
.challenge_action label, .challenge_action input {
display:block;
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
}
.challenge_action input[type="radio"] {
opacity:0.011;
z-index:100;
}
.challenge_action input[type="radio"]:checked + label {
background:yellow;
}
.challenge_action label {
padding:5px;
border:1px solid #CCC;
cursor:pointer;
z-index:90;
}
.challenge_action label:hover {
background:#DDD;
}
<div class="form-group radio_buttons optional challenge_action">
<span class="radio">
<label for="challenge_action_lose_10_pounds">
<input class="radio_buttons optional" type="radio" value="Lose 10 Pounds" name="challenge[action]" id="challenge_action_lose_10_pounds" />Lose 10 Pounds
</label>
</span>
<span class="radio">
<label for="challenge_action_exercise">
<input class="radio_buttons optional" type="radio" value="Exercise" name="challenge[action]" id="challenge_action_exercise" />Exercise
</label>
</span>
</div>
最佳答案
只需使用 collection_radio_buttons
参见 here和 here详情
f.collection_radio_buttons :action, [['Lose 10 Pounds','Lose 10 Pounds'], ['Exercise','Exercise']], :first, :last
关于javascript - 如何将单选按钮变成 CSS 按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35368936/
我已经阅读了这个答案https://stackoverflow.com/a/45486495/1108891 ,它演示了元组类型推断。经过一些实验,我遇到了这种情况。 当我们的 tuple 函数有 T
我想删除零, 我喜欢这个模型,如果我输入 1000 然后额外的表显示从 1 到 1000 的所有数字,每个数字都会检查并删除零。 示例:如果我输入 10然后输出如 1 2 3 .....8 9 1(1
鉴于我对PowerShell的了解仍在开发中,请与我一起提出任何建议/答案。 因此,在我工作的地方我们工作的公司拥有大量日文机器,需要注册Intune。但是,我们正在运行的脚本无法在其计算机上运行,
我刚刚制作了一个将路径保存到 INI 文件中的小程序。 但是在输出中,路径是这样写的: C:\\Windows 我想这样写: C:\Windows 我用 string.replace 尝试了很多方法,
所以我尝试 std::replace(diff_path.begin(), diff_path.end(), "\\", "/"); 但它似乎无法在我的 Visual Studio 上编译.怎么办 -
我使用以下代码每 30 秒自动抓取/设置最新的页面标题: setInterval(function() { var data = "http://mysite.com/mypage
我希望有两个 View 是组成集的一部分。每个 View 中的数据最好在 UITableView 中表示。然后,我想添加一个手势来使 View 在屏幕上闪烁,并引入另一个类似的 View ,并带有页面
我正在尝试开发一个小游戏,但我遇到了以下问题:我有一个伪类“Cannon”,每个 Cannon 都有一个存储它应该守卫的区域的数组和一个存储“入侵者”的数组进入其中一个戒备区。我创建了下一个函数作为
当我从应用程序中进行插入时,所有 ★(星号)都会变成“â…” 如何阻止这种情况发生? *如果我直接通过 phpmyadmin 插入它,它就可以工作,但使用这个 php 时则不行: connect_er
我遇到了一个奇怪的问题,将 NSDictionary 存储到 NSUserDefaults,然后检索它会将其转换为 NSCFString。 这是我保存数据的地方: - (void)saveProgre
我正在尝试像这样向 coinbase api 发出请求 $url = "https://api.gdax.com/products/BTC-USD/candles?start=".date($form
我在 HTTP header 中使用 if-modified-since 来决定是否应该下载文件。应用程序已经过测试,一切正常,但现在当我询问我的 NSHTTPURLResponse 实例 respo
我向串口发送0xFF 结果是 0x3F。 所有其他字节都是正确的。 情况是这样的…… 外部盒子将这些字节发送到 PC... 0xFF, 0x0D, 0x00, 0x30, 0x31, 0x53, 0x
所以我在我的 Next JS 应用程序中遇到了这个奇怪的问题,我导入了谷歌字体,如下所示 在我的浏览器中显示的不是 href,而是 data-href="...",所以问题是谷歌无法将此识别为链接
我试图通过将 QRect 变成 QPolygon 来检查 QPolygon 和 QRect 之间的碰撞。但是,矩形也可能有我添加的旋转,所以我想知道如何将 QRect 变成 QPolygon 并考虑到
我正在尝试写一个 Conduit使用 attoparsec解析器。具体来说,给定 parseOne :: Parser T , 我想构建一个 Conduit ByteString m T重复地将解析器
标记内的超链接
我正在尝试添加 和 所以实际的文字出现在我的页面上。不是链接。 所以我希望在我的页面上显示实际的 HTML,如下所示: 目前,出现了一个死图像...我想 单独阻止了这一点,只是显示了普通的html?
最近发现一些路由器设备包含后门,some of which可以通过单个UDP数据包加以利用。我意识到其中一些后门不一定是恶意的,因为我在自己的产品中也做了同样的事情以进行故障排除:打开套接字将心跳数据
我知道我可以将 iOS 设备变成 iBeacons ( Can an iOS7 device act as an iBeacon? )。不幸的是,我只有一台设备,我的信标还没有到达。所以我想知道如何将
有没有人尝试过将 MAC 变成 iBeacon。我已经为 iOS 设备完成了此操作,并且想要一个类似的带有一些 UI 的 MAC 独立应用程序。我听说 Mavericks 上的新 API 支持 iBe
我是一名优秀的程序员,十分优秀!