html5 - 求解关于伪类和搜索框动画的问题
阿神
阿神 2017-04-17 11:20:22
[HTML讨论组]

先放出代码:

<!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;
        }
        p{
            width:240px;
            height: 30px;
        }
    </style>
</head>
<body>
    <p>
        <input type="text">
        <button  type="button"><img src="images/search2.png"></button>
   </p>
</body>
</html>

效果如图所示
图1图2

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

阿神
阿神

闭关修行中......

全部回复(1)
PHP中文网

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

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

p:hover button {
    background-color: #0066CC;
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号