css表单

具有亲和力的表单样色,兼容IE和firefox下正常显示。

先看看效果:

form.jsp

<% @ page contentType = " text/html; charset=utf-8 "  language = " java "  import = " java.sql.* "  errorPage = ""   %>
< script  type ="text/javascript"  src ="../common/js_css/form.js" ></ script >
< link  rel ="stylesheet"  type ="text/css"  media ="screen"  href ="../common/js_css/form.css"   />

< div  class ="replyForm" >
< form  id =""  name =""  class ="cmxform"  method ="post"  action ="" >
    
< class ="pLeft" > 星号的为必填部分  < em > * </ em ></ p >
    
< fieldset >
        
< legend  align ="center" > 发表评论 </ legend >
        
< ol >
            
< li >< label  for ="zt" >< em > * </ em > 昵称: </ label >   < input  id ="zt"  name ="zt"  width ="50%"   /></ li >
            
< li >< label  for ="zt" >< em > &nbsp;&nbsp; </ em > 密码: </ label >   < input  id ="zt"  name ="zt"  width ="50%"   /> 游客发言不需要密码. </ li >
            
< li >< label  for ="zt" >< em > * </ em > 验证码: </ label >   < input  id ="zt"  name ="zt"  width ="50%"   /></ li >
            
< li >< label  for ="comments" >< em > * </ em > 内容: </ label >   < textarea  id ="nr"  name ="nr"  style ="width:75%; height:200px;" ></ textarea ></ li >
        
</ ol >
    
</ fieldset >
    
< p >< input  type ="button"  id ="SubmitButton"  name ="SubmitButton"  onclick ="SubmitForm('messageForm')"  value ="发表评论"   />< input  type ="reset"  value ="重写" ></ p >
    
< class ="pRight" > 虽然发表评论不用注册,但是为了保护您的发言权,建议您 < tip =""  href ="http://suncss.com/register.asp" > 注册帐号 </ a ></ p >
</ form >
</ div >

 

form.css

@import "formReset.css";

@import "formStyle.css";

 

formReset.css

/* *********************************
Use: Reset Styles for all browsers
Author: ison
**********************************
*/
a img, iframe 
{  border :  none ;   }
/*
Headers------------------------------
*/
h1, h2, h3, h4, h5, h6 
{ margin :  0 ;     padding :  0 ;     font-size :  100% ; }
/*
Lists------------------------------
*/
ul, ol, dl, li, dt, dd 
{ margin :  0 ;     padding :  0 ; }
/*  
Links------------------------------
*/
a, a:link 
{}
a:visited 
{}
a:hover 
{}
a:active 
{}
/*  
Forms------------------------------
*/
form, fieldset 
{ margin :  0 ;     padding :  0 ; }
fieldset 
{  border :  1px solid #000 ;   }
legend 
{ padding :  0 ; color :  #000 ; }
input, textarea, select 
{ margin :  0 ;     padding :  1px ; font-size :  100% ; font-family :  inherit ; }
select 
{  padding :  0 ;   }

/* *********************************
Use: Core Styles
**********************************
*/
{  margin :  10px 0 ;   }
.sr 
{
    position
:  absolute ;
    left
:  -9999em ;
    top
:  0 ;
    width
:  1px ;
    height
:  1px ;
    overflow
:  hidden ;
}

 

formStyle.css

/* *********************************
Use: cmxform Styles
Author: ison 
**********************************
*/
.divForm
{  margin : 5px 0 0 5px ;  width : 96% ; }
form.cmxform 
{ width : 100% ;  height : 100% ; font-size :  1.1em ; color :  #333 ; }
form.cmxform p
{ text-align : center ; }
form.cmxform p.pLeft
{ text-align : left ; }
form.cmxform p.pRight
{ text-align : right ; }
form.cmxform legend 
{  padding-left :  0 ;   }
form.cmxform legend,form.cmxform label 
{  color :  #333 ;   }
form.cmxform fieldset 
{
    border
:  none ;
    border-top
:  1px solid #C9DCA6 ;
    background
:  url(../image/cmxform-fieldset.gif) left bottom repeat-x ;
}
form.cmxform fieldset fieldset 
{  background :  none ;   }
form.cmxform fieldset li 
{
    padding
:  5px 10px 7px ;
    background
:  url(../image/cmxform-divider.gif) left bottom repeat-x ;
}

/* *********************************
Use: cmxform template
Author: Nick Rigby
**********************************
*/
form.cmxform fieldset 
{  margin-bottom :  10px ;   }
form.cmxform legend 
{ padding :  0 2px ; font-weight :  bold ; _margin :  0 -7px ;   /*  IE Win  */ }
form.cmxform label 
{ display :  inline-block ; line-height : 1.8 ; vertical-align : top ; }
form.cmxform fieldset ol 
{ margin :  0 ; padding :  0 ; }
form.cmxform fieldset li 
{ list-style :  none ; padding :  5px ; margin :  0 ; }
form.cmxform fieldset label 
{  width : 12% ; }
.titleStyle
{  width : 88% }
.inputStyle
{  width : 88% }
form.cmxform fieldset fieldset 
{ border :  none ; margin :  3px 0 0 ; }
form.cmxform fieldset fieldset legend 
{ padding :  0 0 5px ; font-weight :  normal ; }
form.cmxform fieldset fieldset label 
{ display :  block ; width :  auto ; }
form.cmxform em 
{ font-weight :  bold ; font-style :  normal ; color :  #f00 ; }
form.cmxform label 
{  width :  120px ;   }   /*  Width of labels  */
form.cmxform fieldset fieldset label 
{  margin-left :  123px ;   }   /*  Width plus 3 (html space)  */
/* *//* / form.cmxform legend { display: inline-block; } /* IE Mac legend fix  */

 

脚本下载:form.js

背景图片:cmxform-divider.gif      cmxform-fieldset.gif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
HTML 表单是一个包含表单元素的区域,表单元素是允许用户在表单输入内容,比如:文本框、下拉列表、单选框、复选框等等。 以下是一个基本的 HTML 表单: ```html <form> <label for="username">用户名:</label> <input type="text" id="username" name="username"><br><br> <label for="password">密码:</label> <input type="password" id="password" name="password"><br><br> <label for="gender">性别:</label> <select id="gender" name="gender"> <option value="male">男</option> <option value="female">女</option> <option value="other">其他</option> </select><br><br> <label>爱好:</label><br> <input type="checkbox" id="hobby1" name="hobby1" value="reading"> <label for="hobby1">阅读</label><br> <input type="checkbox" id="hobby2" name="hobby2" value="music"> <label for="hobby2">听音乐</label><br> <input type="checkbox" id="hobby3" name="hobby3" value="sports"> <label for="hobby3">运动</label><br><br> <input type="submit" value="提交"> </form> ``` 上面的代码中,我们使用了 `<form>` 元素来创建一个表单表单中包含了几个不同类型的表单元素,比如:文本框、密码框、下拉列表和复选框等。每个表单元素都有一个 `name` 属性和一个 `id` 属性,这些属性用于标识表单元素。 在表单的最后,我们使用了一个 `<input>` 元素来创建一个提交按钮,这个按钮将用户输入的数据提交到服务器。 接下来,我们使用 CSS 来美化这个表单: ```css form { width: 400px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; background-color: #f5f5f5; } label { display: inline-block; width: 80px; text-align: right; } input[type="text"], input[type="password"], select { width: 220px; padding: 5px; border: 1px solid #ccc; border-radius: 3px; background-color: #fff; font-size: 16px; line-height: 1.5; box-sizing: border-box; } select { height: 30px; } input[type="checkbox"] { vertical-align: middle; } ``` 上面的 CSS 代码中,我们使用了一些常见的属性,比如 `width`、`margin`、`padding`、`border`、`border-radius`、`background-color` 等等,这些属性可以用来控制表单的样式。 我们还使用了一些伪类选择器,比如 `:hover`、`:focus` 等等,这些选择器可以用来控制表单元素的交互效果。 最终,我们得到了一个美观、实用的 HTML 表单

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值