overlay

嗨,为了重现这个

:root{
    --black: rgb(11, 14, 17);
    --green: rgb(112, 228, 80);
    --gray: rgb(55, 55, 55);
}

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    width: 100%;
    height: 100%;
    background-color: var(--black);
    color: #eee;
}

#rect-bar{
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    overflow: hidden;
}

#rect-bar .rect-row{
    width: 100%;
    height: 150px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    /* border: 1px solid white; */
}

#rect-bar .rect-row .rect-cube{
    margin: 5px;
    width: 150px;
    height: 150px;
    border-radius: 15px;
    background-color: var(--green);
    /* border: 1px solid white; */
}

#rect-bar .rect-row .rect-cube.rcg{
    width: 120px;
    height: 120px;
    background-color: var(--gray);
}
<div id="rect-bar">
  <div class="rect-row">
    <div class="rect-cube rcg">
    </div>
    <div class="rect-cube">
    </div>
  </div>
  <div class="rect-row">
    <div class="rect-cube">
    </div>
    <div class="rect-cube rcg">
    </div>
  </div>
</div>

我一整天都在想这个问题,不知道两个绿色矩形的中间部分是如何相互连接的.

如果你能给我一些好主意,我将非常高兴.

推荐答案

不是我想要的最好的方式,但这也会工作.

所以基本上,创建一个2x2布局,风格它你喜欢的边框,背景 colored颜色 .然后在它下面加一层假层,用其中一个匹配的相对幼崽的匹配 colored颜色 填充空隙.

body {
    background-color: #0a0e11;
}
.square-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    width: 200px;
    height: 200px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}
.square-wrapper:before {
    content: "";
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 50%;
    height: 50%;
    background-color: #2be72b;
}
.square-wrapper > [class*="cell"] {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 10px solid #2be72b;
    border-radius: 20px;
    background-color: #2be72b;
    position: relative;
}
.square-wrapper .cellA, .square-wrapper .cellD {
    background-color: #2e2f31;
    border-radius: 20px;
    border-color: #0a0e11;
    color: white;
}
<div class="square-wrapper">
    <div class="cellA">A</div>
    <div class="cellB">B</div>
    <div class="cellC">C</div>
    <div class="cellD">D</div>
</div>

Css相关问答推荐

如何将bslib::card()中的扩展按钮移到右上方,其中full_screen = TRUE?

如何在Ionic上更改输入的浮点数名称 colored颜色 ?

如何在横向和纵向布局上使用 CSS 网格中的纵横比来保持纵横比

更改行数时更改 CSS 网格列

Bootstrap 5 - 更改列顺序时出现问题

flex 容器中的两个滚动块

使用 CSS 无限期地闪烁两个不同持续时间的文本

在 CSS 或 JavaScript 中反转图像的 colored颜色

svg 背景图像位置始终在 Internet Explorer 中居中,尽管 background-position: left center;

使用 CSS/HTML 更改悬停图像

最大宽度与最小宽度

如何更改 Angular Material 上 mat-icon 的大小?

溢出的文本可以居中吗?

数据协议 URL 大小限制

是否允许在链接中嵌套链接?

使用没有设置宽度或高度的边界半径的胶囊形状?

bootstrap 关闭响应菜单点击

脉动的心脏 CSS 动画

我可以在 css 中指定 maxlength 吗?

仅使用 css 的换行符(如
)