使用transform实现搜索框里面的三角形而不用字体图标

<!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试试。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值