扫码关注官方订阅号
有这样一段HTML:
RepoBranch
想要用css绘制出下图的效果:
应该如何写这段CSS?
光阴似箭催人老,日月如移越少年。
大概是这么个意思,楼主你看一下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> .shape { margin-left: -100px; } .shape:first-child { margin-left: 0; } .shape span { display: inline-block; line-height: 100px; width: 220px; background: #3abf28; vertical-align: top; color: white; font-size: 40px; font-family: Arial; text-align: center; } .shape:before { display: inline-block; content: ""; border-left: 50px solid rgba(0, 0, 0, 0); border-top: 50px solid #3abf28; border-bottom: 50px solid #3abf28; } .shape:after { display: inline-block; content: ""; border-left: 50px solid #3abf28; border-top: 50px solid rgba(0, 0, 0, 0); border-bottom: 50px solid rgba(0, 0, 0, 0); border-right: 50px solid rgba(0, 0, 0, 0); } </style> </head> <body> <p><span class="shape"><span>Repo</span></span></p> </body> </html>
左侧的三角用before,右侧的三角用after
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
大概是这么个意思,楼主你看一下:
左侧的三角用before,右侧的三角用after