网站首页 > 知识剖析 正文
使用css的border边框属性和宽度高度可以实现各种形状的图形,如下:
梯形
html:
<div class="trapezoid"></div>
css:
/*梯形*/
.trapezoid {
width: 80px; height: 0;
border: 40px solid #fff;
border-top: 0 solid;
border-bottom: 80px solid #b4a078;
}
五角星
html:
<div class="star-5-points"></div>
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:
<div class="ribbon"></div>
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:
<div class="masonry"></div>
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:
<div class="heart"></div>
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个形状组成,如下图:
- 上一篇: 渐变色不会调?这10个网站帮你快速搞定
- 下一篇: 如何在设计软件中正确填充颜色的详细指南
猜你喜欢
- 2024-11-20 CSS简写指南
- 2024-11-20 利用CSS filter的属性给img修改颜色
- 2024-11-20 CSS奇思妙想-使用background创造美妙背景(上篇)
- 2024-11-20 HTML5(七)——SVG基础入门
- 2024-11-20 CSS 四个不同大小和颜色的圆环加载动画 #前端开发工程师
- 2024-11-20 花了一整晚三个小时给大家整合的配色网站合集
- 2024-11-20 如何在设计软件中正确填充颜色的详细指南
- 2024-11-20 渐变色不会调?这10个网站帮你快速搞定
- 2024-11-20 css3实现背景颜色渐变的方法
- 2024-11-20 Win11窗口背景颜色如何设置?Win11窗口背景颜色设置的方法
- 最近发表
- 标签列表
-
- xml (46)
- css animation (57)
- array_slice (60)
- htmlspecialchars (54)
- position: absolute (54)
- datediff函数 (47)
- array_pop (49)
- jsmap (52)
- toggleclass (43)
- console.time (63)
- .sql (41)
- ahref (40)
- js json.parse (59)
- html复选框 (60)
- css 透明 (44)
- css 颜色 (47)
- php replace (41)
- css nth-child (48)
- min-height (40)
- xml schema (44)
- css 最后一个元素 (46)
- location.origin (44)
- table border (49)
- html tr (40)
- video controls (49)