html 怎么设置漂亮的表单样式

html-css010

html 怎么设置漂亮的表单样式,第1张

html 设置漂亮的表单样式,以下是代码:

1、编写一个from表单

<form id="payment">

<fieldset>

<legend>用户详细资料</legend>

<ol>

<li>

<label for="name">用户名称:</label>

<input id="name" name="name" type="text" placeholder="请输入用户名" required autofocus>

</li>

<li>

<label for="email">邮件地址:</label>

<input id="email" name="email" type="email" placeholder="[email protected]" required>

</li>

<li>

<label for="phone">联系电话:</label>

<input id="phone" name="phone" type="tel" placeholder="010-12345678" required>

</li>

</ol>

</fieldset>

<fieldset>

<legend>家庭住址(收货地址):</legend>

<ol>

<li>

<label for="address">详细地址:</label>

<textarea id="address" name="address" rows="1" required></textarea>

</li>

<li>

<label for="postcode">邮政编码:</label>

<input id="postcode" name="postcode" type="text" required>

</li>

<li>

<label for="country">国家:</label>

<input id="country" name="country" type="text" required>

</li>

</ol>

</fieldset>

<fieldset>

<legend>付费方式</legend>

<ol>

<li>

<fieldset>

<legend>信用卡类型</legend>

<ol>

<li>

<input id="visa" name="cardtype" type="radio">

<label for="visa">中国工商银行</label>

</li>

<li>

<input id="amex" name="cardtype" type="radio">

<label for="amex">中国人民银行</label>

</li>

<li>

<input id="mastercard" name="cardtype" type="radio">

<label for="mastercard">中国建设银行</label>

</li>

</ol>

</fieldset>

</li>

<li>

<label for="cardnumber">银行卡号:</label>

<input id="cardnumber" name="cardnumber" type="number" required>

</li>

<li>

<label for="secure">验 证 码:</label>

<input id="secure" name="secure" type="number" required>

</li>

<li>

<label for="namecard">持 卡 人:</label>

<input id="namecard" name="namecard" type="text" placeholder="确定是否该卡用户!" required>

</li>

</ol>

</fieldset>

<fieldset>

<button type="submit">现在购买</button>

</fieldset>

</form>

2、编写css样式

<style type="text/css">

/*分别定义HTML中和标记之的距离样式*/

html, body, h1, form, fieldset, legend, ol, li {

margin: 0

padding: 0

}

/*定义<body>标记样式*/

body {

background: #ffffff

color: #111111

font-family: Georgia, "Times New Roman", Times, serif

padding-left: 20px

}

/*定义付费内容的样式*/

form#payment {

background: #9cbc2c

-webkit-border-radius: 5px

border-radius: 5px

padding: 20px

width: 400px

margin:auto

}

form#payment fieldset {

border: none

margin-bottom: 10px

}

form#payment fieldset:last-of-type { margin-bottom: 0}

form#payment legend {

color: #384313

font-size: 16px

font-weight: bold

padding-bottom: 10px

text-shadow: 0 1px 1px #c0d576

}

form#payment >fieldset >legend:before {

content: "Step " counter(fieldsets) ": "

counter-increment: fieldsets

}

form#payment fieldset fieldset legend {

color: #111111

font-size: 13px

font-weight: normal

padding-bottom: 0

}

form#payment ol li {

background: #b9cf6a

background: rgba(255, 255, 255, .3)

border-color: #e3ebc3

border-color: rgba(255, 255, 255, .6)

border-style: solid

border-width: 2px

-webkit-border-radius: 5px

line-height: 30px

list-style: none

padding: 5px 10px

margin-bottom: 2px

}

form#payment ol ol li {

background: none

border: none

float: left

}

form#payment label {

float: left

font-size: 13px

width: 110px

}

form#payment fieldset fieldset label {

background: none no-repeat left 50%

line-height: 20px

padding: 0 0 0 30px

width: auto

}

form#payment fieldset fieldset label:hover { cursor: pointer}

form#payment input:not([type=radio]), form#payment textarea {

background: #ffffff

border: #FC3 solid 1px

-webkit-border-radius: 3px

font: italic 13px Georgia, "Times New Roman", Times, serif

outline: none

padding: 5px

width: 200px

}

form#payment input:not([type=submit]):focus, form#payment textarea:focus {

background: #eaeaea

border: #F00 solid 1px

}

form#payment input[type=radio] {

float: left

margin-right: 5px

}

</style>

3、漂亮的表单生成。

启动dreamweaver,点击“站点”---“新建站点”

2

在弹出的窗口中,站点名称为“漂亮按钮”,本地站点文件夹可以根据需要选择。点击“保存”按钮,站点创建成功。

END

二、创建css文件

1

点击“文件”----“新建”,在弹出的窗体中选择“空白页”-----“CSS”,然后点击“创建”按钮。

2

点击“文件”----“保存”,在文件名中输入“style”,然后点击“保存”,样式表文件创建成功。

END

三、创建html页面

1

点击“文件”----“新建”,在弹出的窗体中选择“空白页”-----“HTML”---“无”。

2

在附加CSS文件中,选择style.css样式表文件,点击“确定”。

3

点击“创建”按钮,生成HTML文件。点击“文件”----“保存”按钮,文件名设置为“index”,最后点击保存即可。

END

三、在html页面中添加一个按钮控件

1

在“插入”-----“表单”中,点击“按钮”

2

在弹出的对话框中,什么也不需要修改,直接点击“确定”。

3

在弹出窗口中,选择“是“

4

按钮添加成功,效果如下。

END

四、新建CSS规则

1

在CSS样式表中,选择“新建CSS规则“

2

在弹出的窗口中选择”类(可应用于任何HTML元素)“,选择器名称设置为“btnstyle”,然后点击“确定”。

3

然后,在找到按钮控件,将它的类设置为”btnstyle”

END

五、用CSS规则修改按钮控件的外观

1

.btnstyle {

width: 86px/*按钮控件的宽度*/

text-align: center/*按钮控件中文本居中显示*/

line-height: 100%/*用百分比设置行高*/

padding-top: 0.5em/*文本顶部的内边距*/

padding-right: 2em/*文本右侧的内边距*/

padding-bottom: 0.55em/*文本底部的内边距*/

padding-left: 2em/*文本左侧的内边距*/

font-family: "Arial Black", Gadget, sans-serif/*字体*/

font-size: 14px/*字体大小*/

font-style: normal/*字体样式*/

font-variant: normal/*小写字母*/

font-weight: normal/*文本不需要加粗*/

text-decoration: none/*文本不需要下划线等*/

margin-top: 0px/*外边框的距离*/

margin-right: 2px/*外边框的距离*/

margin-bottom: 0px/*外边框的距离*/

margin-left: 2px/*外边框的距离*/

vertical-align: text-bottom/*图像放在文本下面*/

display: inline-block/*段落内生出内框*/

cursor: pointer/*鼠标的形状*/

zoom:1

outline-width:medium/*整个轮廓的宽度*/

outline-color:inherit/*轮廓的颜色*/

font-size-adjust:none

font-stretch:normalhttp://v.youku.com/v_show/id_XMTMzMTM0ODIzMg==.html

border-top-left-radius:0.5em/*圆角边框弧度*/

border-top-right-radius:0.5em/*圆角边框弧度*/

border-bottom-left-radius:0.5em/*圆角边框弧度*/

border-bottom-right-radius:0.5em/*圆角边框弧度*/

box-shadow:0px 1px 2px rgba(0,0,0,0.2)/*给按钮增加阴影*/

color:#fefee9/*设置文本的颜色*/

border-top-color:#da7c0c/*边框的颜色*/

border-right-color:#da7c0c/*边框的颜色*/

border-bottom-color:#da7c0c/*边框的颜色*/

border-left-color:#da7c0c/*边框的颜色*/

border-top-width:1px/*边框的粗细*/

border-right-width:1px/*边框的粗细*/

border-bottom-width:1px/*边框的粗细*/

border-left-width:1px/*边框的粗细*/

border-top-style:solid/*边框的样式*/

border-right-style:solid/*边框的样式*/

border-bottom-style:solid/*边框的样式*/

border-left-style:solid/*边框的样式*/

background-image:none/*背景图片*/

background-attachment:scroll/*背景图片是否移动*/

background-repeat:repeat/*允许重复*/

background-position-x:0%/*背景的x轴坐标*/

background-position-y:0%/*背景的y轴坐标*/

background-size:auto/*背景图片的尺寸*/

background-origin:padding-box/*背景图像相对于内边距框来定位*/

background-clip:padding-box/*背景被裁剪到内边距框*/

background-color:#f78d1d/*背景颜色*/

}更多学习5 1 r g b

2

再写一句mybtn的hover样式。代码如下:

.btnstyle:hover {

background-color: #f47c20

}