我目前正在尝试弄清楚如何制作弹出窗口/表单助手。如果你真的不知道我在说什么,这就是我指的: http://www.ashrobbins.com/wp-content/uploads/2012/01/sliding-form-helpers.png
我想做如下的事情:
#1:用户位置是红色方 block 。黄色方 block 是相关的,所以黄色大方 block 显示的是第一个方 block 的信息。这就是我的意思: http://postimage.org/image/wgzedx2fv/
PS:注意第三列的框要大!
#2 对于这一步,当用户转到第二行(红色方 block )时,我希望第三列中的框更改为对应于第二行的信息。希望这会有所帮助: http://postimage.org/image/69y7hyk63/
我不知道该怎么做。我目前正在使用 RoR 和 Bootstrap,但我不确定它是否有任何关系,它可能只与 CSS/HTML 有关。
我已经尝试为我的 html 做这样的事情并且它在一定程度上起作用,但它看起来不像我想要的那样好。
任何事情都会有所帮助。 谢谢!
更新: 根据要求,我有一些这样的代码:
<div class="span4" style="margin-left: 0px; ">
<div class="span3" style="margin-left: 0px; ">here where the explanation will go</div>
或者我的 RoR:
- 查看
= render :partial => 'shared/unitrow', :locals => {:f => f, :main_input => :offwarfare, :input_label => "Offensive", :power => OFFWARFARE_POWER}
- 部分
%div{:id => "wrapper"}
=f.input main_input, :label => input_label, :input_html => { :class => 'unitinputstyle'}, :wrapper_html => { :class => "unitinputdiv" }
%=div{:class => "unitpricediv"}
=power
%div{:class => "clear"}
仅供引用,我使用的是 HAML。我只是不能在这里正确地设计它的样式......
最佳答案
对于客户端发生的任何动态事件(如 DOM 操作),您都需要使用 Javascript。我已经使用 jQuery 为您编写了一个示例;但您可以自由使用您喜欢的任何库(或根本不使用)。
$("#interactiveForm input").focus(function() {
var target = $(this).attr("id"); // Gets the ID of the focused input
$("#infoBox p:visible").hide(); // Hides visible content (if any)
$("#infoBox").find("p#"+target).show(); // Shows the paragraph with the corresponding ID
});
关于html - 如何做 HTML/CSS 表单助手/popover,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9898832/