css input按钮 鼠标悬停改变颜色

html-css017

css input按钮 鼠标悬停改变颜色,第1张

给你个例子,用onmousemove和nmouseout。具体css颜色等自己改一下。

<style>

.input_out{width:60pxheight:30pxborder:1pxsolid#CCCbackground-color:#FFF}

.input_move{width:60pxheight:30pxborder:1pxsolid#CCCbackground-color:#FFFFCC}

</style><inputtype="button"class="input_out"onmousemove="this.className='input_move'"onmouseout="this.className='input_out'"value="提交"/>

涉及到input里的文字的标签大致有两种——文本框和按钮,即:

这两种input标签属于“行内块元素”,它既按照块元素显示外观,又按照行内元素排列,所以想调整其内部的文字位置可按照块元素的方法来。下面是示例(仅以button为例,text同理):

文字左右对齐,可使用text-align属性来控制,例如:

文字上下对齐,可使用padding-top和padding-bottom来精确控制,例如文字靠下。

<!DOCTYPE html>

<html>

<head>

<style>

#btn{background:red}

#btn:hover{background:blue}

</style>

</head>

<body>

<input id="btn" type="button"/>

</body>

</html>

经验证是可以的,或许是你的图片路径不对,不过ie6不支持伪类:hover属性,所以如果要兼容ie6就用js或者,用a标签来代替吧