关于给input、div添加hover样式,边框变大后里面的文字移动问题-解决办法

<style>
        div {
            width: 200px;
            height: 30px;  
        }
        input {
            width: 200px;
            height: 30px;
            border: 1px solid #ccc;
            font-size: 12px;
            line-height: 24px;
        }
        input:hover {
            border: 2px solid #d9d9d9;
        }
    </style>
</head>

<body>
    <div>
        <input type="text" placeholder="电话号">
    </div>
</body>

</html>

这样写,鼠标移上去后input里的文字就会移动

解决办法,给要增大边框先预留一个空间,可以input添加一个padding:1px;  然后鼠标以上去在设置为0,input:hover{padding:0px}; 

posted @ 2020-07-17 17:28  云柯-  阅读(1447)  评论(0编辑  收藏  举报