css 我怎样才能使花式角在我的网站

huwehgph  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(73)

我想做一个像这张图中的角

我是一个前端开发的初学者。我试过这个,但我现在卡住了。
代码:

* {
  margin: 0;
  padding: 0;
}

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  background-color: white;
  border-radius: 15px
}

.box {
  text-align: center;
  font-size: 50pt;
}

#top {
  background-color: blue;
  position: relative;
  border-bottom-left-radius: 50px
}

#top:after {
  content: "";
  position: absolute;
  right: 0;
  top: 100%;
  height: 100px;
  width: 100px;
  border-top-right-radius: 50%;
  box-shadow: 0 -50px 0 0 black;
}

#bottom {
  background-color: red;
  position: relative;
}

个字符
这段HTML和CSS代码定义了一个网页,它有一个居中的容器,包含两个框,一个有蓝色背景(“顶部”)和装饰性阴影,另一个有红色背景(“底部”)。样式包括圆角和居中的文本。

vjhs03f7

vjhs03f71#

我只需要在顶部和底部添加额外的容器来设置相反的背景颜色

* {
  margin: 0;
  padding: 0;
}

body {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.container {
  background-color: white;
  border-radius: 15px
}

.box {
  text-align: center;
  font-size: 50pt;
}

#OuterTop {
  background-color: red;
}

#OuterBottom {
  background-color: blue;
}

#top {
  background-color: blue;
  position: relative;
  border-bottom-left-radius: 50px;
}

#bottom {
  background-color: red;
  border-top-right-radius: 50px;
  position: relative;
}

个字符

hiz5n14c

hiz5n14c2#

我会这样做...
简单地用双色(左,右)作为背景。

:root {
  --clear    : #e8eaff;
  --dark     : #18183a;
  }
* {
  margin     : 0;
  box-sizing : border-box;
  }
.container { 
  border-radius : 30px;
  width         : 200px;
  background    : linear-gradient(90deg, var(--clear) 50%, var(--dark) 50%);
  margin        : 2em;
  } 
.container > div {
  border-radius : inherit;
  padding       : 30px;
  }
.container > div:first-of-type {
  background : var(--dark);
  color      : var(--clear);
  height     : 150px;
  }
.container > div:last-of-type {
  background : var(--clear);
  color      : var(--dark);
  height     : 200px;
  }

个字符

相关问题