在https://login.mailchimp.com/signup上,当您点击表单(:焦点)时,下方会显示“帮助信息”。例如“你的电子邮件地址是什么?”出现在电子邮件下方。
我试图分析他们的CSS但我没有在我的代码上应用这样的东西。 我想我错过了一些重要的东西,比如告诉程序我希望它在用户点击字段时显示。
这是我的代码
Rails视图:
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-vertical' }) do |f| %>
<fieldset>
<%= f.error_notification %>
<%= display_base_errors resource %>
<%= f.input :email, :required => true, placeholder: t("devise.registrations.sign_up_page.whats_your_email_address") %>
<div class="field-help"> What's your email address? </div>
<%= f.input :password, :required => true %>
<%= f.input :password_confirmation, :required => true %>
<div class="fullsized"><%= f.button :submit, t("devise.registrations.sign_up_page.sign_up"), :class => 'btn-primary' %>
</div>
</fieldset>
<% end %>
的CSS:
.field-help {
-webkit-transition: all 0.25s ease-in-out 0s;
-moz-transition: all 0.25s ease-in-out 0s;
-o-transition: all 0.25s ease-in-out 0s;
-ms-transition: all 0.25s ease-in-out 0s;
transition: all 0.25s ease-in-out 0s;
display: block;
opacity: 0;
max-height: 0;
top: -1.8461538461538463em;
overflow: hidden;
white-space: normal;
width: 100%;
max-width: 550px;
word-wrap: break-word;
font-size: 0.8125em;
line-height: 1.3846153846153846em;
font-weight: 700;
position: relative;
color: #737373;
letter-spacing: .01em
}
答案 0 :(得分:1)
你应该使用CSS3淡入/淡出天赋。尝试添加此样式:
fieldset input:focus+.field-help {
opacity:1;
top: 0;
max-height: 20px;
margin-bottom:10px;
}