CSS小例子(只显示下划线的文本框,像文字一样的按钮)

html-css09

CSS小例子(只显示下划线的文本框,像文字一样的按钮),第1张

只显示下划线的文本框,像文字一样的按钮

body{

background-color:#daeeff

/*

页面背景色

*/

}

form{

margin:0px

padding:0px

font:14px

}

input{

font:14px

Arial

}

.txt{

color:#005aa7

border-bottom:1px

solid

#005aa7

/*

下划线效果

*/

border-top:0px

border-left:0px

border-right:0px

background-color:transparent

/*

背景色透明

*/

}

.btn{

background-color:transparent

/*

背景色透明

*/

border:0px

/*border:0px

solid

#005aa7边框取消

*/

cursor:pointer

}

用户名:

密 码:

[Ctrl+A

全选

注:如需引入外部Js需刷新才能执行]

比如做一个导航条

首先搭建基本机构:

<div id="menu">

<ul>

<li><a href="#">首页</a></li>

<li><a href="#">年表</a></li>

<li><a href="#">作品</a></li>

<li><a href="#">文章</a></li>

<li><a href="#">画廊</a></li>

<li><a href="#">留言</a></li>

<li><a href="#">地图</a></li>

</ul>

</div>

这时候看到的一个纵列文字前带圆点的列表

然后用css进行美化:

#menu {

background-color: #6282ac

height: 35px

width: 570px

position: relative

}

定义菜单的宽,高,颜色及定位方式。

#menu ul {

list-style-type: none

}

去掉文字下划线。

#menu li {

float: left

display: block

width: 60px

height: 31px

margin-top: 2px

margin-right: 6px

margin-bottom: 2px

margin-left: 6px

line-height: 31px

text-align: center

background-repeat: repeat-x

border: 1px solid #FFFFFF

}

定义“float: left”使列表项横向排列,设置高与行高使链接文字垂直居中。

menu a {

font-family: Arial, Helvetica, sans-serif

font-size: 10px

background-image: url(../images/b.gif)

display: block

background-repeat: repeat-x

}

定义链接的字体及背景

#menu a:hover{

background-image: url(../images/a.gif)

display: block

background-repeat: repeat-x

}

定义a的伪类实现鼠标点击时的背景变化