css三角形实现原理 不必做成图片或者字体图标
你就知道 CSS 三角是形实现原怎么来的了, 做法如下:
div { width: 0; height: 0; border: 50px solid transparent; border-color: red green blue black; line-height:0; font-size: 0; }我们用css 边框可以模拟三角效果
宽度高度为0
我们4个边框都要写,不必做成图片或者字体图标。形实现原
一张图,形实现原加上 font-size: 0; line-height: 0;
案例:京东三角
效果图

代码参考
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>CSS 三角制作</title> <style> .box1 { width: 0; height: 0; /* border: 10px solid pink; */ border-top: 10px solid pink; border-right: 10px solid red; border-bottom: 10px solid blue; border-left: 10px solid green; } .box2 { width: 0; height: 0; border: 50px solid transparent; border-left-color: pink; margin: 100px auto; } .jd { position: relative; width: 120px; height: 249px; background-color: pink; } .jd span { position: absolute; right: 15px; top: -10px; width: 0; height: 0; /* 为了照顾兼容性 */ line-height: 0; font-size: 0; border: 5px solid transparent; border-bottom-color: pink; } </style></head><body> <div></div> <div></div> <div> <span></span> </div></body></html>都改为 transparent 透明就好了 为了照顾兼容性 低版本的形实现原浏览器,
网页中常见一些三角形,形实现原其余的形实现原不能省略,使用 CSS 直接画出来就可以,形实现原 只保留需要的形实现原边框颜色,
100平房子装修价格是多少 100平房子装修方法
10平米儿童房设计技巧 10平米儿童房设计技巧介绍
逾百名全国中老年足球爱好者佛山“以赛会友”
2026中国网球匹克球双拍赛暨首届“国金杯”上海站收官
经典好句好段摘选
精装修房子怎么装修介绍 精装修房子装修风格
中国队获得青奥会历史首枚体操女子团体金牌
颗粒物传感器打破”烟花爆竹中的年味”与PM2.5环境危害的壁垒 年俗亦应与时俱进
灵气复苏:我的武魂是八大恶魔
全球媒体聚焦
评论
发表评论