我已經找到了一個櫥櫃的代碼板。使用CSS創建櫥櫃
我真的可以將它用於我的網站,但是當我嘗試添加兩個貨架時,最下面的兩個貨架都在櫃子外面。當玩弄櫃子的高度時,貨架只是收縮/增長,但底部的2個貨架仍然在櫃子外面。
我嘗試在底層貨架上添加邊框,但情況更糟。
我試着製作一個只有2個架子的櫥櫃,但是你會在底部得到這個醜陋的棕色方形。
爲什麼我看到所有這些問題?
.cabinet {
position: absolute;
width: 460px;
height: 500px;
background-color: #45221c;
top: 40px;
left: 30%;
border: 10px solid #69342b;
box-sizing: border-box;
}
.cabinet .cabinet-top {
width: 104%;
height: 0;
border-bottom: 10px solid #572b23;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
box-sizing: border-box;
top: -20px;
left: -2%;
position: absolute;
}
.cabinet .shelf {
position: relative;
width: 100%;
height: 20%;
box-sizing: border-box;
}
.cabinet .shelf .back {
position: absolute;
top: 0;
left: 2%;
width: 96%;
height: 100%;
background: #2c1512;
box-shadow: inset 10px 15px 15px #21100d;
}
.cabinet .shelf .base {
width: 100%;
height: 0;
border-bottom: 20px solid #331915;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
box-sizing: border-box;
bottom: 10px;
position: absolute;
}
.cabinet .shelf .front {
width: 100%;
height: 10px;
background-color: #69342b;
position: absolute;
bottom: 0;
}
<div class="cabinet">
<div class="cabinet-top"></div>
<div class="shelf">
<div class="upper-left-triangle"></div>
<div class="upper-right-triangle"></div>
<div class="back"></div>
<div class="base"></div>
<div class="front"></div>
</div>
<div class="shelf">
<div class="upper-left-triangle"></div>
<div class="upper-right-triangle"></div>
<div class="back"></div>
<div class="base"></div>
<div class="front"></div>
</div>
<div class="shelf">
<div class="upper-left-triangle"></div>
<div class="upper-right-triangle"></div>
<div class="back"></div>
<div class="base"></div>
<div class="front"></div>
</div>
<div class="shelf">
<div class="upper-left-triangle"></div>
<div class="upper-right-triangle"></div>
<div class="back"></div>
<div class="base"></div>
<div class="front"></div>
</div>
<div class="shelf">
<div class="upper-left-triangle"></div>
<div class="upper-right-triangle"></div>
<div class="back"></div>
<div class="base"></div>
<div class="front"></div>
</div>
<div class="shelf">
<div class="upper-left-triangle"></div>
<div class="upper-right-triangle"></div>
<div class="back"></div>
<div class="base"></div>
<div class="front"></div>
</div>
<div class="shelf">
<div class="upper-left-triangle"></div>
<div class="upper-right-triangle"></div>
<div class="back"></div>
<div class="base"></div>
<div class="front"></div>
</div>
</div>
CODEPEN:
http://codepen.io/cogitatio/pen/dpword?editors=1100