关于给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}; 

原文地址:https://www.cnblogs.com/yunke/p/13331459.html