网站首页 > 基础教程 正文
使用css的border边框属性和宽度高度可以实现各种形状的图形,如下:
梯形
html:
css:
/*梯形*/
.trapezoid {
width: 80px; height: 0;
border: 40px solid #fff;
border-top: 0 solid;
border-bottom: 80px solid #b4a078;
}
五角星
html:
css:
.star-5-points {
width: 0; height: 0;
position: relative;
margin: 50px 0;
border: 80px solid rgba(0,0,0,0);
border-top: 0 solid;
border-bottom: 56px solid red;
transform: rotateZ(35deg);
}
.star-5-points::before {
content: "";
width: 0;
height: 0;
position: absolute;
top: -36px;
left: -52px;
border: 24px solid rgba(0,0,0,0);
border-top: 0 solid;
border-bottom: 64px solid red;
transform: rotateZ(-35deg);
}
.star-5-points::after {
content: "";
width: 0;
height: 0;
position: absolute;
top: 3px;
left: -86px;
border: 80px solid rgba(0,0,0,0);
border-top: 0 solid;
border-bottom: 56px solid red;
transform: rotateZ(-70deg);
}
带子形状
html:
css:
.ribbon {
width: 0;
height: 80px;
border: 40px solid #56ad66;
border-top: 0 solid;
border-bottom: 28px solid rgba(0,0,0,0);
}
钻石形状
这个图形由2部分组成,当上部图形的背景色比下部背景色浅时就会有点立体效果,如下图。
html:
css:
/*上部图形背景色*/
.masonry {
width: 50px; height: 0;
position: relative;
margin: 20px 0 82px;
border: 25px solid rgba(0,0,0,0);
border-top-width: 0;
border-bottom-color: #b4a078;
}
/*下部图形背景色*/
.masonry::after {
content: "";
width: 0; height: 0;
position: absolute;
top: 25px; left: -25px;
border: 50px solid rgba(0,0,0,0);
border-top: 70px solid #b4a078;
border-bottom-width: 0;
}
心形
html:
css:
.heart {
content: "";
display: block;
width: 100px;
min-height: 80px;
position: relative;
transform-origin: 50% 50% 0;
}
/*左边形状*/
.heart:before {
content: "";
display: block;
width: 50px; height: 80px;
position: absolute;
top: 0; left: 50px;
border-radius: 50px 50px 0 0;
background: #ff66ff;
transform: rotateZ(-45deg);
transform-origin: 0 100% 0;
}
/*右边形状*/
.heart:after {
content: "";
display: block;
width: 50px; height: 80px;
position: absolute;
top: 0; left: 0;
border-radius: 50px 50px 0 0;
background: #ff66ff;
transform: rotateZ(45deg);
transform-origin: 100% 100% 0;
}
心形由左右2个形状组成,如下图:
- 上一篇: 前端兼容性问题总结(前端兼容性问题总结怎么写)
- 下一篇: 如何使用CSS实现旋转地球动画效果
猜你喜欢
- 2025-03-28 做个简单的本地弹幕播放器(做个简单的本地弹幕播放器软件)
- 2025-03-28 如何使用CSS实现旋转地球动画效果
- 2025-03-28 前端兼容性问题总结(前端兼容性问题总结怎么写)
- 2025-03-28 CSS 样式表小结(css样式表的使用方法有几种)
- 2025-03-28 用CSS实现居中的七种方法(css中如何居中)
- 2025-03-28 JS如何判断文字被ellipsis了?(js判断某字段是否存在)
- 2025-03-28 CSS3的3D属性详解,附示例代码。(css30)
- 2025-03-28 CSS 水平居中方式二(css水平居中行内元素)
- 2025-03-28 css——定位(css定位路径)
- 2025-03-28 CSS实现常见元素水平、垂直居中(css元素垂直居中的方法)
- 最近发表
- 标签列表
-
- jsp (69)
- pythonlist (60)
- gitpush (78)
- gitreset (66)
- python字典 (67)
- dockercp (63)
- gitclone命令 (63)
- dockersave (62)
- linux命令大全 (65)
- mysql教程 (60)
- pythonif (68)
- pythonifelse (59)
- deletesql (62)
- c++模板 (62)
- linuxgzip (68)
- 字符串连接 (73)
- nginx配置文件详解 (61)
- html标签 (69)
- c++初始化列表 (64)
- mysqlinnodbmyisam区别 (63)
- arraylistadd (66)
- console.table (62)
- mysqldatesub函数 (63)
- window10java环境变量设置 (66)
- c++虚函数和纯虚函数的区别 (66)