gpt4 book ai didi

html - CSS 3D 容器,如帖子中所示

转载 作者:太空宇宙 更新时间:2023-11-04 12:24:58 25 4
gpt4 key购买 nike

我一直在尝试使用 html 和 css 将这个容器框放入我的网页中。但我似乎无法让它正常工作,谁能帮我解决这个问题?

目前我没有任何代码,因为我一直在复制和粘贴教程并试图弄清楚它是如何工作的,但我似乎无法做到正确。

enter image description here

最佳答案

使用pseudo elements

影子更新

:root{background: #c7c7c7; padding: 80px;}
div{
background: white;
width: 280px;
height: 480px;
position: relative;
margin: 0px auto
}

div:before, div:after{
content: "";
position: absolute;
background: #f2f2f2
}
div:before{
left: 100%;
width: 40px;
height: 100%;
top: 0;
top: 20px;
transform: skew(0deg,45deg);
box-shadow: 2px 1px 1px 0px #9D9C9C, 0 2px 2px #f2f2f2;
}
div:after{
top: 100%;
width: 100%;
height: 40px;
left: 20px;
transform: skew(45deg,0deg);
box-shadow: -2px 2px 1px 0px #9D9C9C, 8px 0 16px #f2f2f2
}
<div><div/>

无影更新

:root{background: #c7c7c7; padding: 80px;}
div{
background: white;
width: 280px;
height: 480px;
position: relative;
margin: 0px auto
}

div:before, div:after{
content: "";
position: absolute;
background: #f2f2f2
}
div:before{
left: 100%;
width: 40px;
height: 100%;
top: 0;
top: 20px;
transform: skew(0deg,45deg);
}
div:after{
top: 100%;
width: 100%;
height: 40px;
left: 20px;
transform: skew(45deg,0deg);
}
<div><div/>

旧更新

:root{background-color: #c7c7c7; height: 100vh}
main{
width: calc(100vw - 100px);
height: 120vh;
margin: 20px;
background: white;
position: relative
}
main:before, main:after{
position: absolute;
content: "";
}

main:before{
height: calc(100% - 40px);
width: 50px;
background: #f2f2f2;
right: -50px;
top: 40px
}
main:after{
height: 0;
width: 0;
top: 0;
right: -50px;
border-top: 40px solid transparent;
border-bottom: 0px solid transparent;
border-left: 50px solid #f2f2f2;
}
<main></main>

或阴影

:root{background-color: #c7c7c7; height: 100vh}
main{
width: calc(100vw - 100px);
height: 120vh;
margin: 20px;
background: white;
position: relative;
box-shadow: 50px 0 #f2f2f2;
}
main:before{
position: absolute;
content: "";
width: 0;
height: 0;
border-right: 50px solid #c7c7c7;
border-bottom: 50px solid transparent;
right: -50px;
top: 0;
}
<main></main>

关于html - CSS 3D 容器,如帖子中所示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28083635/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com