gpt4 book ai didi

html - 没有图像的 CSS3 多边形,如何?

转载 作者:太空狗 更新时间:2023-10-29 14:13:21 24 4
gpt4 key购买 nike

我正在建立一个网站,它是这样的 without expansion

顶部的两个结构是静态的,底部的四个是动态的,当我说动态时,我的意思是可扩展的,像这样

with expansion

因为这些只是颜色、形状和阴影,我相信可以使用 CSS3 来创建它们。但是我很难这样做。我什至尝试使用 CSSHat,但结果很糟糕。

这是示例形状 individual shape

这是生成的代码:

width: 1920px;
height: 341px;
-moz-border-radius: 0 1920px 1920px / 0 181px 56px;
-webkit-border-radius: 0 1920px 1920px / 0 181px 56px;
border-radius: 0 1920px 1920px / 0 181px 56px; /* border radius */
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box; /* prevents bg color from leaking outside the border */
background-color: #3b0f1d; /* layer fill content */

结果是这样的: converted shape可以在这里找到一个实例 http://codepen.io/seraphzz/pen/mgDwd

实现此目标的最佳方式是什么?

最佳答案

您可以使用 CSS transforms 来旋转 div。

我已将底部 div 设为动态,并向黄色绿色 div 添加了一些内容。

body {
margin: 0;
padding: 0;
overflow-x: hidden;
}
.top, .top2, .yellow, .green, .bottom, .bottom2 {
height: 200px;
width: 140%;
position: relative;
left: -10%;
transform-origin: 0% 100%;
transition: 0.6s ease;
}
.top {
top: -180px;
background: #3C101D;
transform: rotate(4deg);
}
.top2 {
background: #931930;
transform: rotate(-1.5deg);
}
.yellow {
background: #F0810E;
top: -200px;
transform: rotate(0.6deg);
}
.content {
display: block;
width: 65%;
position: relative;
top: 10%;
left: 10%;
}
.yellow .content {
transform: rotate(-0.6deg);
}
.green {
background: #425949;
top: -320px;
transform: rotate(-1.4deg);
}
.green .content {
transform: rotate(1.4deg);
}
.bottom {
background: #501B2B;
top: -480px;
transform: rotate(1.4deg);
}
.bottom2 {
background: #3C101D;
top: -600px;
transform: rotate(-0.6deg);
}
.yellow:hover, .green:hover, .bottom:hover, .bottom2:hover {
height: 400px;
}
<div class="top"></div>
<div class="top2"></div>
<div class="yellow">
<div class="content">But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</div>
</div>
<div class="green">
<div class="content">But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</div>
</div>
</div>
<div class="bottom"></div>
<div class="bottom2"></div>

关于html - 没有图像的 CSS3 多边形,如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16813560/

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