当前位置: 首页 > news >正文

怎样不引入图片实现前端css实现x关闭按钮

  1. 首先初始化一个dom节点
<span class="closeButton"></span>
  1. 设置样式
.closeButton {width: 12px;height: 12px;margin-top: 5px;margin-right: 5px;float: right;cursor: pointer;color: #105c86;}
  1. 通过伪元素before after画两条线
    margin-left 的设置是为了处理’线’的自身宽度
 &::before,&::after {position: absolute;// right: 0;width: 2px;height: 12px;margin-left: 2px;content: '';background: #105c86;}
  1. 分别试着旋转角度
   &::before {transform: rotate(-45deg);}&::after {transform: rotate(45deg);}

完整代码

.closeButton {width: 12px;height: 12px;margin-top: 5px;margin-right: 5px;float: right;cursor: pointer;color: #105c86;&::before,&::after {position: absolute;// right: 0;width: 2px;height: 12px;margin-left: 2px;content: '';background: #105c86;}&::before {transform: rotate(-45deg);}&::after {transform: rotate(45deg);}
}

参考网页
https://www.nowcoder.com/discuss/517014650349744128?fromPut=jj-blog&urlSource=extension-api

http://www.lryc.cn/news/137381.html

相关文章:

  • SpringBoot实现文件下载的多种方式
  • uniapp简单版语音播放
  • 前端三剑客入门一文解决
  • php curl apache 超时 500错误
  • ValueError: too many values to unpack (expected 4)
  • 学习Vue过程中遇到的问题汇总
  • cloud_mall-notes03
  • Redis注入中出现的问题
  • 机器学习实战之模型的解释性:Scikit-Learn的SHAP和LIME库详解
  • 【网络安全】防火墙知识点全面图解(二)
  • 【计算机视觉 | 目标检测】arxiv 计算机视觉关于目标检测的学术速递(8 月 14 日论文合集)
  • 自学设计模式(类图、设计原则、单例模式 - 饿汉/懒汉)
  • python爬虫10:selenium库
  • c++ java rgb与nv21互转
  • 多视图聚类(multi-view clustering)简介
  • wazhu配置以及漏洞复现
  • javaweb项目部署linux服务器遇到的问题
  • 【数据结构OJ题】环形链表
  • PySpark-核心编程
  • vue 在IOS移动端中 windon.open 等跳转外部链接后,返回不触发vue生命周期、mounted等相关事件-解决方法
  • 股票预测和使用LSTM(长期-短期-记忆)的预测
  • Docker搭建个人网盘、私有仓库
  • 3种获取OpenStreetMap数据的方法【OSM】
  • 数据处理与统计分析——MySQL与SQL
  • OpenCV之特征点匹配
  • 浅谈开关柜绝缘状态检测与故障诊断
  • Mybatis 动态 SQL
  • Android studio之 build.gradle配置
  • 【ElasticSearch】一键安装IK分词器无需其他操作
  • 在Ubuntu上启动一个简单的用户登录接口服务