gpt4 book ai didi

html - 使用 Flexbox 组织的带有 microTiles 的响应式 Div

转载 作者:行者123 更新时间:2023-11-28 02:47:23 24 4
gpt4 key购买 nike

#theTeamWrapper {
position: relative;
width: 100%;
height: auto;
background-image: url('https://www.kuboland.com/integra/images/bgTexture-01.png');
background-size:cover;
text-align: center;
display: block;
padding-top: 140px;
padding-bottom: 20px;
}

#megaWrapper {
width:90%;
height:auto;
background-color: ;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-content: flex-start;
position: relative;
margin: 0 auto;
}

#tile {
width:180px;
height:180px;
margin: 20px;
color: #fff;
font-family: 'Montserrat';
position:relative;
}

#tileHover {
background-color: rgba(0, 0, 0, 0.7);
position: absolute;
width:100%;
height: 100%;
opacity:0;
transition: opacity 0.2s ease;
cursor: pointer;
}

#tileHover:hover {
opacity:1;
}

.tileText {
font-size:18px;
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
margin: 0 auto;
width:90%;
}

.tileSubText {
font-size:12px;
opacity: 0.8;
}

#tileType {
width:180px;
height:180px;
background-color: #fdd108;
margin: 20px;
color: #fff;
font-family: 'Montserrat';
position:relative;

}

.tileType {
position: absolute;
left:0;
top:0;
margin-top: -12px;
font-size:40px;
}

.tileType2 {
font-family: 'Open Sans', sans-serif;
position: absolute;
right: 0;
bottom: 0;
margin-bottom: -8px;
font-size: 25px;
color:#fff;
}

.founder1 {
background-image: url('');
background-size: cover;
background-color: green;
}

.founder2 {
background-image: url('');
background-size: cover;
background-color: green;
}

.founder3 {
background-image: url('');
background-size: cover;
background-color: green;
}

.employee1 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee2 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee3 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee4 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee5 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee6 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee7 {
background-image: url('');
background-size: cover;
background-color: pink;
}

.employee8 {
background-image: url('');
background-size: cover;
background-color: pink;
}

.employee9 {
background-image: url('');
background-size: cover;
background-color: pink;
}
<div id="theTeamWrapper">

<div id="megaWrapper">
<div id="tileType">
<h3 class="tileType">
TEAM
</h3>
<h3 class="tileType2">
A
</h3>
</div>

<div id="tile" class="founder1">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="founder2">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="founder3">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="megaWrapper">
<div id="tileType">
<h3 class="tileType">
TEAM
</h3>
<h3 class="tileType2">
B
</h3>
</div>

<div id="tile" class="employee1">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee2">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee3">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee4">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee5">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee6">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="megaWrapper">
<div id="tileType">
<h3 class="tileType">
TEAM
</h3>
<h3 class="tileType2">
C
</h3>
</div>

<div id="tile" class="employee7">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee8">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee9">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

</div>
</div>

我有一个 Div,其中包含很多图 block ,每个图 block 都有名称和标题,还有一些描述性图 block ,例如“team1”、“team2”和“team3”

每个 Tile 都是 180x180px,我正在尝试使用这个响应式包装器来实现这一点

enter image description here

有 3 组颜色的图 block ,黄色将该组描述为 A、B 或 C。一旦一个图 block 向下移动到另一行,因为没有更多空间,我希望它打破那条线,下一组从这个开始。

我的代码作为 https://jsfiddle.net/yw81cxzc/1/

不确定我做错了什么,有什么建议吗?

最佳答案

您遗漏了#megaWrapper 的一些结束标签,这使得它们在错误的位置关闭并且基本上将它们相互包裹起来。您还可以删除 justify-content: space-around;来自#megaWrapper。这应该会处理所有事情,除非您需要它进一步居中。

#theTeamWrapper {
position: relative;
width: 100%;
height: auto;
background-image: url('https://www.kuboland.com/integra/images/bgTexture-01.png');
background-size: cover;
text-align: center;
display: block;
padding-top: 140px;
padding-bottom: 20px;
}

#megaWrapper {
width: 90%;
height: auto;
background-color: ;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
position: relative;
margin: 0 auto;
}

#tile {
width: 180px;
height: 180px;
margin: 20px;
color: #fff;
font-family: 'Montserrat';
position: relative;
}

#tileHover {
background-color: rgba(0, 0, 0, 0.7);
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
transition: opacity 0.2s ease;
cursor: pointer;
}

#tileHover:hover {
opacity: 1;
}

.tileText {
font-size: 18px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0 auto;
width: 90%;
}

.tileSubText {
font-size: 12px;
opacity: 0.8;
}

#tileType {
width: 180px;
height: 180px;
background-color: #fdd108;
margin: 20px;
color: #fff;
font-family: 'Montserrat';
position: relative;
}

.tileType {
position: absolute;
left: 0;
top: 0;
margin-top: -12px;
font-size: 40px;
}

.tileType2 {
font-family: 'Open Sans', sans-serif;
position: absolute;
right: 0;
bottom: 0;
margin-bottom: -8px;
font-size: 25px;
color: #fff;
}

.founder1 {
background-image: url('');
background-size: cover;
background-color: green;
}

.founder2 {
background-image: url('');
background-size: cover;
background-color: green;
}

.founder3 {
background-image: url('');
background-size: cover;
background-color: green;
}

.employee1 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee2 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee3 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee4 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee5 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee6 {
background-image: url('');
background-size: cover;
background-color: blue;
}

.employee7 {
background-image: url('');
background-size: cover;
background-color: pink;
}

.employee8 {
background-image: url('');
background-size: cover;
background-color: pink;
}

.employee9 {
background-image: url('');
background-size: cover;
background-color: pink;
}

<div id="theTeamWrapper">

<div id="megaWrapper">
<div id="tileType">
<h3 class="tileType">
TEAM
</h3>
<h3 class="tileType2">
A
</h3>
</div>

<div id="tile" class="founder1">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="founder2">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="founder3">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>
</div>
<div id="megaWrapper">
<div id="tileType">
<h3 class="tileType">
TEAM
</h3>
<h3 class="tileType2">
B
</h3>
</div>

<div id="tile" class="employee1">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee2">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee3">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee4">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee5">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee6">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>
</div>
<div id="megaWrapper">
<div id="tileType">
<h3 class="tileType">
TEAM
</h3>
<h3 class="tileType2">
C
</h3>
</div>

<div id="tile" class="employee7">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee8">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>

<div id="tile" class="employee9">
<div id="tileHover">
<h3 class="tileText">
NAME
<br>
<span class="tileSubText">Title</span>
</h3>
</div>
</div>
</div>
</div>

关于html - 使用 Flexbox 组织的带有 microTiles 的响应式 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46852178/

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