如何做HTML/CSS表单助手/ popover

问题描述:

我目前正在试图弄清楚如何做popovers /表单助手。如果你真的不知道我在说什么,这就是我所说的: http://www.ashrobbins.com/wp-content/uploads/2012/01/sliding-form-helpers.png如何做HTML/CSS表单助手/ popover

我会想这样做如下:

#1:用户位置是红色正方形。和黄色正方形是相关的,所以我大黄色正方形显示关于第一个正方形的信息。这里就是我的意思是: http://postimage.org/image/wgzedx2fv/

PS:请注意,在第三栏框必须要大!

#2 对于此步骤,当用户转到第二行(红色方块)时,我希望第三列中的方框更改为对应于第二行的信息。希望这会有所帮助: 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>

还是我的回报率:

  • 查看

= 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。我只是不能在这里正确地设计它...

+0

您可以张贴的jsfiddle与您的代码? – 2012-03-27 22:52:54

+0

你从哪里得到信息?您是否想根据所选输入字段动态显示内容? – 2012-03-27 22:59:53

+0

您好@BethBudwig,我添加了我认为相关的部分代码。 – 2012-03-27 23:17:37

对于在客户端动态发生的任何事情(如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 
}); 

http://jsfiddle.net/LQNS8/