这里有一个jsbin http://jsbin.com/suvajux/1/edit?html,css,output到目前为止,我所拥有的和下面是我正在尝试构建的图像:
这是 html,到目前为止我只添加了金字塔的 2 条边:
<div class="pyramid-container">
<div id="pyramid">
<div class="base"></div>
<div></div>
<div></div>
</div>
</div>
这是CSS:
.pyramid-container {
perspective: 800px;
}
#pyramid {
position: relative;
transform-style: preserve-3d;
transform-origin: 116px 200px 116px;
padding-left: 100px;
margin-top: 50px
}
#pyramid div:not(.base) {
position: absolute;
width: 0;
height: 0;
border-left: 100px solid transparent; /* left arrow slant */
border-right: 100px solid transparent; /* right arrow slant */
border-bottom: 100px solid; /* bottom, add background color here */
font-size: 12px;
line-height: 0;
opacity: .5;
}
.base {
position: absolute;
width: 200px;
height: 200px;
background-color: #ff0000;
transform: rotateX(80deg) translate3d(0px, 10px, 0px);
}
#pyramid div:nth-child(2) {
border-bottom-color: blue;//#e04545;
transform: rotateX(-30deg) rotateY(0deg) rotateZ(0deg) translate3d(0px, 0px, 100px);
}
#pyramid div:nth-child(3) {
border-bottom-color: yellow;//#ccaf5a;
transform: rotateX(30deg) rotateY(0deg) rotateZ(0deg) translate3d(0px, 25px, 0px);
}
我使用 css3 创建 1 个基本矩形 div 和 4 个三角形 div。
我需要一些有关数学以及如何定位元素的帮助。
我希望三角形的所有 4 条边都在顶点相交,并将三角形的四个底边放置在矩形 div 上。
我正在努力解决如何使不同三角形的点在顶点相遇的问题。
任何人都可以帮助我解决数学问题或使用什么逻辑来实现这一目标。
我不是在寻找代码,而是在寻找更多我应该使用的逻辑或数学。