css3设置元素的边框图像(详解CSS3 用border写 空心三角箭头 两种写法)
类别:Web前端 浏览量:893
时间:2022-01-28 01:48:30 css3设置元素的边框图像
详解CSS3 用border写 空心三角箭头 两种写法之前一直在寻找这种空心三角箭头, 终于知道了原理! 自己记录一下,顺便分享给之前跟我一样想要的撸友们~
第一种写法 利用常见的 after伪元素
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .arrow { width: 20px; height: 4px; margin: 0 auto 7px; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 4px solid #343c99; transform: rotate(45deg); transform-origin: left; } .arrow:after { content: ''; display: block; width: 100%; height: 100%; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 4px solid #343c99; position: absolute; right: -10px; top: -14px; transform: rotate(90deg); transform-origin: bottom; } </style> </head> <body> <li class="arrow"></li> </body> </html>
第二种写法相对于比较简单
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> /*简单*/ .wb_arrow{ border-right: 2px solid #343c99; border-top: 2px solid #343c99; height: 10px; width: 10px; margin:50px auto 0; transform: rotate(deg); -webkit-transform: rotate(0deg); /*不加这两个属性三角会比上一个略丑, 大家可以试一下*/ border-left: 2px solid transparent; border-bottom: 2px solid transparent; } </style> </head> <body> <li class="wb_arrow"></li> </body> </html>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持开心学习网。
热门推荐
- python批量图像换背景(详解Python给照片换底色蓝底换红底)
- SQL中FOR XML PATH
- 小程序详细步骤使用方法(小程序的基本使用知识点非常全面,推荐!)
- docker gitlab 配置(使用Docker构建一个Git镜像使用clone仓库)
- sqlserver实现登录注册(Sqlserver创建用户并授权的实现步骤)
- docker gitlab 配置(使用Docker构建一个Git镜像使用clone仓库)
- 正则表达式中/i,/g,/ig,/gi,/m的含义
- css特效边框流线动画(CSS 动画实现动态气泡背景的方法)
- mysql时间存储如何选择(MySQL如何使用时间作为判断条件)
- vue数据改变页面不刷新(vue列表数据删除后主动刷新页面及刷新方法详解)