CSS 3D 容器,如 post 中所示
CSS 3D containers like shown in post
我一直在尝试使用 html 和 css 将这个容器框放入我的网页。
但我似乎无法让它正常工作,谁能帮我解决这个问题?
目前我没有任何代码,因为我一直在复制和粘贴教程并试图弄清楚它是如何工作的,但我似乎做不对。
更新影子
: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 将这个容器框放入我的网页。 但我似乎无法让它正常工作,谁能帮我解决这个问题?
目前我没有任何代码,因为我一直在复制和粘贴教程并试图弄清楚它是如何工作的,但我似乎做不对。
更新影子
: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>