首页 话题 小组 问答 好文 用户 我的社区 域名交易 唠叨

[分享]css3怎么画出1234

发布于 2024-11-11 15:28:03
0
21

CSS3是一种用于网页排版与设计的编程语言,今天我们来学习如何使用CSS3画出数字1、2、3、4。

/* 数字1 */
.one {
  width: 20px;
  height: 100px;
  background-color: #000;
  position: relative;
  margin: 50px auto;
}

.one::before {
  content: ';
  position: absolute;
  width: 60px;
  height: 20px;
  background-color: #000;
  top: -50px;
  left: -20px;
  transform: rotate(-45deg);
}

/* 数字2 */
.two {
  width: 100px;
  height: 140px;
  position: relative;
  margin: 50px auto;
}

.two::before, .two::after {
  content: ';
  position: absolute;
  width: 60px;
  height: 20px;
  background-color: #000;
  top: 0;
}

.two::before {
  transform: rotate(-45deg);
  left: 0;
}

.two::after {
  transform: rotate(45deg);
  right: 0;
  top: 120px;
}

/* 数字3 */
.three {
  width: 100px;
  height: 140px;
  position: relative;
  margin: 50px auto;
}

.three::before, .three::after {
  content: ';
  position: absolute;
  width: 60px;
  height: 20px;
  background-color: #000;
  top: 20px;
}

.three::before {
  transform: rotate(-45deg);
  left: 0;
}

.three::after {
  transform: rotate(45deg);
  right: 0;
  top: 100px;
}

/* 数字4 */
.four {
  width: 100px;
  height: 140px;
  position: relative;
  margin: 50px auto;
}

.four::before {
  content: ';
  position: absolute;
  width: 20px;
  height: 140px;
  background-color: #000;
  left: 40px;
}

.four::after {
  content: ';
  position: absolute;
  width: 100px;
  height: 20px;
  background-color: #000;
  top: 60px;
} 

以上是用CSS3画出数字1、2、3、4的代码,通过增加数字,可以轻松绘制出更多数字。CSS3使得网页排版与设计更加丰富多彩,希望大家可以多多尝试,开发出更加优美独特的网页。

评论
一个月内的热帖推荐
91云脑
Lv.1普通用户

62849

帖子

14

小组

291

积分

赞助商广告
站长交流