HTML fieldset legend

本文介绍了一个具体的用户表单实现案例,展示了如何使用CSS对表单进行美化,包括背景颜色、字体样式等,并通过Ruby on Rails提供了表单字段及验证错误提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. .depot-form fieldset {
  2.   background#efe;
  3. }
  4. .depot-form legend {
  5.   color#dfd;
  6.   background#141;
  7.   font-familysans-serif;
  8.   padding0.2em 1em;
  9. }
  10. .depot-form label {
  11.   width5em;
  12.   floatleft;
  13.   text-alignright;
  14.   margin-right0.5em;
  15.   displayblock;
  16. }
  17. .depot-form .submit {
  18.   margin-left5.5em;
  19. }
 
  1. <!--
  2.  ! Excerpted from "Agile Web Development with Rails, 2nd Ed.",
  3.  ! published by The Pragmatic Bookshelf.
  4.  ! Copyrights apply to this code. It may not be used to create training material, 
  5.  ! courses, books, articles, and the like. Contact us if you are in doubt.
  6.  ! We make no guarantees that this code is fit for any purpose. 
  7.  ! Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.
  8. -->
  9. <div class="depot-form">
  10.   <%= error_messages_for 'user' %>
  11.   <fieldset>
  12.     <legend>Enter User Details</legend>
  13.     <% form_for :user do |form| %>
  14.       <p>
  15.         <label for="user_name">Name:</label>
  16.         <%= form.text_field :name:size => 40 %>
  17.       </p>
  18.       <p>
  19.         <label for="user_password">Password:</label>
  20.         <%= form.password_field :password:size => 40 %>
  21.       </p>
  22.       <p>
  23.         <label for="user_password_confirmation">Confirm:</label>
  24.         <%= form.password_field :password_confirmation:size => 40 %>
  25.       </p>
  26.       <%= submit_tag "Add User":class => "submit" %>
  27.     
  28.     <% end %>  
  29.   </fieldset>
  30. </div>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值