<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
input {
outline: none;
width: 200px;
height: 30px;
}
.father {
position: relative;
width: 200px;
height: 30px;
}
.father::after {
content: "";
position: absolute;
top: 9px;
right: 11px;
height: 8px;
width: 8px;
border-right: 1px solid #000000;
border-bottom: 1px solid #000000;
transform: rotate(45deg);
transition: all 0.3s;
}
.father:hover::after {
transform: rotate(225deg);
}
</style>
</head>
<body>
<div class="father">
<input type="text" placeholder="输入内容"/>
</div>
</body>
</html>
效果如下图:
使用::after伪类来弄一个只有下和右边框的盒子,然后使用transform里面的rotate实现盒子旋转45度角,形成一个倒三角的样子。
需要注意的是,input 不能使用 ::after 或::before等伪类, input无法容纳其他元素,因此它不支持伪元素。要通过before、after加额外样式时,就得先套个div试试。