css里鼠标悬停变色怎么设置?

html-css014

css里鼠标悬停变色怎么设置?,第1张

css中悬停改变样式的最好方法是用伪类选择器div:hover{}。css代码示例如下:\x0d\x0a\x0d\x0adiv{width:100pxheight:200pxbackground:#000}\x0d\x0adiv:hover{background:#fff}\x0d\x0a\x0d\x0a这是一个修改背景颜色的示例,伪类里可以修改跟多的样式,宽度,高度或者字体大小,字体颜色都是可以修改的。

给你个例子,用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 lang="en">

<head>

    <meta charset="UTF-8">

    <title>Document</title>

    <style type="text/css">

        .parent{

            width: 300px

            height: 100px

            overflow: hidden

            background: yellow

        }

        .parent>div{

            width: 96px

            height: 96px

            border: 2px solid #000

            float: left

        }

        .parent>div:hover{

            border-color: red

        }

    </style>

</head>

<body>

    <div class="parent">

        <div>1</div>

        <div>2</div>

        <div>3</div>

    </div>

</body>

</html>

这样样子并不会盖住呀!