求解关于伪类和搜索框动画的问题


先放出代码:


 <!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        input{
            display: inline-block;
            width:0px;
            height: 30px;
            float: left;
           -webkit-transition: width 1s,height 1s,-moz-transform 1s ;
           -moz-transition: width 1s,height 1s,-moz-transform 1s;
        }
        input:hover{
            width:200px;
            height: 30px;
        }
        button{
            border:none;
            width:35px;
            height: 32px;
            float: left;
            background-color: #2894FF;
        }
        button:hover{
            background-color: #0066CC;
        }
        img{
            width:30px;
            height: 30px;
        }
        div{
            width:240px;
            height: 30px;
        }
    </style>
</head>
<body>
    <div>
        <input type="text">
        <button  type="button"><img src="images/search2.png"></button>
   </div>
</body>
</html>

效果如图所示
图片描述 图1 图片描述 图2

那么问题来了,我把鼠标悬停在搜索框上时搜索框会维持图2,可一旦将鼠标移到放大镜上时就会回到图1,求大神告诉我把鼠标悬停在放大镜上时如何维持图2!

css3 html5

和谐社会花似锦 9 years, 2 months ago

你想要的是input和button hover时都出现图2的样式的话,你把hover放到外面那个div上不就完了?
具体:


 html


 div:hover input {
    height: 30px;
    width: 200px;
}

div:hover button {
    background-color: #0066CC;
}

kisume answered 9 years, 2 months ago

Your Answer