最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

网站中比较不错的表单特效实例代码

来源:懂视网 责编:小采 时间:2020-11-27 18:51:05
文档

网站中比较不错的表单特效实例代码

网站中比较不错的表单特效实例代码:今天来说说对input输入框在处理上的细节处理和心得,其实制作一个符合CSS标准、FF/IE7/IE6等主流浏览器全兼容、符合用户体验的input其实并不难。先点击看看下面的效果先!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 St
推荐度:
导读网站中比较不错的表单特效实例代码:今天来说说对input输入框在处理上的细节处理和心得,其实制作一个符合CSS标准、FF/IE7/IE6等主流浏览器全兼容、符合用户体验的input其实并不难。先点击看看下面的效果先!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 St

今天来说说对input输入框在处理上的细节处理和心得,其实制作一个符合CSS标准、FF/IE7/IE6等主流浏览器全兼容、符合用户体验的input其实并不难。先点击看看下面的效果先!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表单效果</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
body{
font-size:63%;
color:#000;
}
/*input*/
.input_on{
padding:2px 8px 0pt 3px;
height:18px;
border:1px solid #999;
background-color:#FFFFCC;
}
.input_off{
padding:2px 8px 0pt 3px;
height:18px;
border:1px solid #CCC;
background-color:#FFF;
}
.input_move{
padding:2px 8px 0pt 3px;
height:18px;
border:1px solid #999;
background-color:#FFFFCC;
}
.input_out{
/*height:16px;默认高度*/
padding:2px 8px 0pt 3px;
height:18px;
border:1px solid #CCC;
background-color:#FFF;
}
/*form*/
ul.input_test{
margin:20px auto 0 auto;
width:500px;
list-style-type:none;
}
ul.input_test li{
width:500px;
height:22px;
margin-bottom:10px;
}
.input_test label{
float:left;
padding-right:10px;
width:100px;
line-height:22px;
text-align:right;
font-size:1.4em;
}
.input_test p{
float:left;
_margin-top:-1px;
}
.input_test span{
float:left;
padding-left:10px;
line-height:22px;
text-align:left;
font-size:1.2em;
color:#999;
}
</style>
</head>
<body>
<ul class="input_test">
<li>
<label for="inp_name">姓名:</label>
<p><input id="inp_name" class="input_out" name="" type="text" onfocus="this.className='input_on';this.onmouseout=''" onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};" onmousemove="this.className='input_move'" onmouseout="this.className='input_out'" /></p>
<span>请输入您的姓名</span>
</li>
<li>
<label for="inp_email">Email:</label>
<p><input id="inp_email" class="input_out" name="" type="text" onfocus="this.className='input_on';this.onmouseout=''" onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};" onmousemove="this.className='input_move'" onmouseout="this.className='input_out'" /></p>
<span>请输入您的Email</span>
</li>
<li>
<label for="inp_web">网站:</label>
<p><input id="inp_web" class="input_out" name="" type="text" onfocus="this.className='input_on';this.onmouseout=''" onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};" onmousemove="this.className='input_move'" onmouseout="this.className='input_out'" /></p>
<span>请输入您的网站</span>
</li>
</ul>
</body>
</html>

鼠标经过input时的颜色会发生变化,此外当点击标题处(<label>的作用)或者输入框时,光标停留所在的input的颜色也和其他input输入框有所不同,这是<input>中JS的作用。在用户体验上告诉的用户什么是可以输入以及当前在什么输入位置。此外通过键盘上Tab键的切换,输入完当前内容移动到下一个输入框变得更方便了,这是CSS合理布局结构的作用。

整体的结构通过<ul>和<li>来组织,每个<li>显示一行内容。<label>标签显示标题,<p>input控制输入框,<span>显示备注信息。这里要特别说一下<input>在各个浏览器下不同的表现,对<input>设置line-height对FF是不起作用的,所以建议用padding来控制文本在输入框的位置。<input>在浏览器下的默认高度和字体一样是16px,加上下边框就是18px。特别是在需要将<input>变大的情况下,用padding来控制比较好。

再来说说JS部分,这里用到onblur(光标离开)、onfocus(光标停留)、onmousemove(鼠标停留)、onmouseout(鼠标离开)这4个属性来控制鼠标的动作。不会JS也没关系,只要定义其所对应的CSS样式就可以了。

文档

网站中比较不错的表单特效实例代码

网站中比较不错的表单特效实例代码:今天来说说对input输入框在处理上的细节处理和心得,其实制作一个符合CSS标准、FF/IE7/IE6等主流浏览器全兼容、符合用户体验的input其实并不难。先点击看看下面的效果先!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 St
推荐度:
标签: 中的 网站 特效
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top