仅在 CSS 中隐藏框给定边缘的溢出

发布于 2025-01-19 19:39:36 字数 412 浏览 2 评论 0原文

嗨,我想制作一个3D盒设计,看起来像 从盒子 出来的对象。

  • 这里的一个图像将在一个盒子内。
  • 图像将比容器盒大。
  • 我想隐藏左右的溢出。

我正在努力从4个小时起为此设计而努力,但没有得到结果和解决方案。

这是我要构建的演示:

”在此处输入图像描述”

Hi I want to make a 3D box design, That should looks like object coming out from box.

  • Here one images will be there inside a box.
  • Image will be bigger than container box.
  • I want to hide overflow from left and bottom only.

I am struggling for making this design since 4 hours, but not getting result and solutions.

Here is the demo that i wants to build:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷梦 2025-01-26 19:39:36

您能检查一下

我使用网格布局模型吗?您可以将图像放入内部.container具有位置:绝对;

*,
*::before,
*::after {
  box-sizing: border-box;
}


img,
picture {
  max-width: 100%;
  display:block;
}

body{
  min-height: 100vh;
  display: grid;
  place-content: center;
}


.container{
  display: grid;
  grid-template-columns: 1fr 2fr 1fr ;
  grid-template-rows: 1fr 3fr 1fr;
  width: 750px;
  height: 750px;
  /* background-color: tomato; */
  position: relative;
}

.box{
  position: relative;
  background-color: tomato;
  z-index:2;
}


.box-1{
  grid-column: 2 / 4;
  grid-row: 1;
  z-index:1;
}

.box-2{
  grid-column: 3;
  grid-row: 2 / 3;
  z-index:1;
}

.box-3{
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  background-color: yellowgreen;
  z-index:1;
}


.box-4{
  grid-column: 1;
  grid-row: 1 / -1;
  
  overflow: hidden;
}

.box-5{
  grid-column: 2 / -1;
  grid-row: 3;
  overflow: hidden;
}

.box-6{
  position: absolute;
  z-index: 1;
}
<div class="container">
      <div class="box-1 box"></div>
      <div class="box-2 box"></div>
      <div class="box-3 box"></div>
      <div class="box-4 box"></div>
      <div class="box-5 box"></div>
      <div class="box-6">
        <img src="https://source.unsplash.com/random/780x400" alt="" />
      </div>
</div>

Can you please check this

I use grid layout model. You can place your image inside .container has position: absolute; on it

*,
*::before,
*::after {
  box-sizing: border-box;
}


img,
picture {
  max-width: 100%;
  display:block;
}

body{
  min-height: 100vh;
  display: grid;
  place-content: center;
}


.container{
  display: grid;
  grid-template-columns: 1fr 2fr 1fr ;
  grid-template-rows: 1fr 3fr 1fr;
  width: 750px;
  height: 750px;
  /* background-color: tomato; */
  position: relative;
}

.box{
  position: relative;
  background-color: tomato;
  z-index:2;
}


.box-1{
  grid-column: 2 / 4;
  grid-row: 1;
  z-index:1;
}

.box-2{
  grid-column: 3;
  grid-row: 2 / 3;
  z-index:1;
}

.box-3{
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  background-color: yellowgreen;
  z-index:1;
}


.box-4{
  grid-column: 1;
  grid-row: 1 / -1;
  
  overflow: hidden;
}

.box-5{
  grid-column: 2 / -1;
  grid-row: 3;
  overflow: hidden;
}

.box-6{
  position: absolute;
  z-index: 1;
}
<div class="container">
      <div class="box-1 box"></div>
      <div class="box-2 box"></div>
      <div class="box-3 box"></div>
      <div class="box-4 box"></div>
      <div class="box-5 box"></div>
      <div class="box-6">
        <img src="https://source.unsplash.com/random/780x400" alt="" />
      </div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文