是否可以在CSS中构建以下设计?
我一直在尝试使用html/css构建以下设计:
png“ rel =” nofollow noreferrer“>
但是现在我已经卡住了,没有自最近两天以来取得了进展 - 所以我正在寻求帮助!
另外,是否有可能做出响应?
为了实现上述我,我编写了以下代码:
.contain {
position: absolute;
height: 400px;
width: 700px;
left: 5%;
}
.hex {
position: absolute;
width: 125px;
height: 200px;
border-radius: 25px;
background: green;
}
.hex:before {
position: absolute;
content: '';
width: 100%;
height: 100%;
border-radius: 25px;
transform: rotate(60deg);
background: green;
}
.hex:after {
position: absolute;
content: '';
width: 100%;
height: 100%;
border-radius: 25px;
transform: rotate(-60deg);
background: green;
}
.innerHexagon {
width: 100px;
height: 152px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: green;
border-top: 2px solid white;
border-bottom: 2px solid white;
border-radius: 20px;
}
.innerHexagon:before {
content: '';
width: 100%;
height: 100%;
position: absolute;
transform: rotate(60deg);
background: green;
border-radius: 20px;
border-top: 2px solid white;
border-bottom: 2px solid white;
}
.innerHexagon:after {
content: '';
width: 100%;
height: 100%;
position: absolute;
transform: rotate(-60deg);
background: green;
border-radius: 20px;
border-top: 2px solid white;
border-bottom: 2px solid white;
}
.test {
position: absolute;
width: 1600px;
/*width: 400px;*/
height: 200px;
z-index: -1;
border-right: 0px;
background: grey;
border-radius: 30px;
}
.test:before {
position: absolute;
content: '';
width: 140px;
/*width: 35%;*/
height: 100%;
transform: rotate(60deg);
left: 1460px;
/*left: 260px;*/
border-radius: 30px;
background: grey;
}
.test:after {
position: absolute;
content: '';
width: 140px;
/*width: 35%;*/
height: 100%;
transform: rotate(-60deg);
left: 1460px;
/*left: 260px;*/
border-radius: 30px;
background: grey;
}
.text {
padding-top: 25px;
padding-left: 50px;
font-size: xx-large;
font-family: sans-serif;
color: Black;
position: absolute;
width: 100%;
text-align: center;
z-index: 1;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style1.css">
</head>
<body>
<div class="contain">
<div class="hex">
<div class="innerHexagon" style="z-index:1">
</div>
</div>
<div class="test">
</div>
<div class="hex" style="left: 500px">
<div class="innerHexagon" style="z-index:1">
</div>
</div>
<div class="hex" style="left: 1000px">
<div class="innerHexagon" style="z-index:1">
</div>
</div>
</div>
</body>
</html>
I have been trying to build the following design using html/css:
So far I have been able to achieve the following:
but now I'm stuck and have not made progress since the last 2 days - so I am looking for help!
Also, is it possible to make this responsive?
To achieve the above I have written the following code:
.contain {
position: absolute;
height: 400px;
width: 700px;
left: 5%;
}
.hex {
position: absolute;
width: 125px;
height: 200px;
border-radius: 25px;
background: green;
}
.hex:before {
position: absolute;
content: '';
width: 100%;
height: 100%;
border-radius: 25px;
transform: rotate(60deg);
background: green;
}
.hex:after {
position: absolute;
content: '';
width: 100%;
height: 100%;
border-radius: 25px;
transform: rotate(-60deg);
background: green;
}
.innerHexagon {
width: 100px;
height: 152px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: green;
border-top: 2px solid white;
border-bottom: 2px solid white;
border-radius: 20px;
}
.innerHexagon:before {
content: '';
width: 100%;
height: 100%;
position: absolute;
transform: rotate(60deg);
background: green;
border-radius: 20px;
border-top: 2px solid white;
border-bottom: 2px solid white;
}
.innerHexagon:after {
content: '';
width: 100%;
height: 100%;
position: absolute;
transform: rotate(-60deg);
background: green;
border-radius: 20px;
border-top: 2px solid white;
border-bottom: 2px solid white;
}
.test {
position: absolute;
width: 1600px;
/*width: 400px;*/
height: 200px;
z-index: -1;
border-right: 0px;
background: grey;
border-radius: 30px;
}
.test:before {
position: absolute;
content: '';
width: 140px;
/*width: 35%;*/
height: 100%;
transform: rotate(60deg);
left: 1460px;
/*left: 260px;*/
border-radius: 30px;
background: grey;
}
.test:after {
position: absolute;
content: '';
width: 140px;
/*width: 35%;*/
height: 100%;
transform: rotate(-60deg);
left: 1460px;
/*left: 260px;*/
border-radius: 30px;
background: grey;
}
.text {
padding-top: 25px;
padding-left: 50px;
font-size: xx-large;
font-family: sans-serif;
color: Black;
position: absolute;
width: 100%;
text-align: center;
z-index: 1;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style1.css">
</head>
<body>
<div class="contain">
<div class="hex">
<div class="innerHexagon" style="z-index:1">
</div>
</div>
<div class="test">
</div>
<div class="hex" style="left: 500px">
<div class="innerHexagon" style="z-index:1">
</div>
</div>
<div class="hex" style="left: 1000px">
<div class="innerHexagon" style="z-index:1">
</div>
</div>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够为那些白色条提出这个解决方案。我已经为目的添加了
span
element.hex
div,并在您的原始样式结束时添加了样式。至于响应部分,您需要详细介绍您希望设计在不同屏幕上的表现的详细信息,以便我们能够以这种方式提供帮助。I was able to come up with this solution for those white strips. I have added
span
element inside.hex
div for the purpose and added styles at the end of your original styles. As for the responsive part, you need to elaborate the details on how you want the design to behave on different screens so we may be able to help that way.