CSS之实现搜索图标

247 阅读1分钟

1、html代码

<div class="icon-search"/>

2、css代码

.icon-search {
  width: 12px;
  height: 12px;
  border-radius: 100%;
  border: 2px solid #000000;
  position: relative;
  margin: 30px auto;
}

.icon-search:after {
  //通过伪元素设置搜索图标的底部,使用绝对定位,宽度8px,高度2px,顺时针旋转45content: '';
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  transform: rotate(45deg);
  width: 8px;
  height: 2px;
  position: absolute;
  top: 10px;
  left: 9px;
  background-color: #000000;
}

3、实现效果

image.png