【发布时间】:2023-03-13 01:21:02
【问题描述】:
我的文本出现问题,我根本看不到它,或者它不像我认为它会出现在弹性框中一样。我现在在 flexbox 中有三个图像,但我想在每个图像下放置小的“标题”(不是在 p 元素中,紫色,但我想将它放在白色上,就在紫色框(p元素)。我认为通过添加一个子元素,该元素至少会与它上面的元素垂直对齐,但我想我错了。有人能帮忙吗?另一条信息真的是我的图像是 250 像素,但我想适应 sn-p,所以我将其设为 50 像素,但这可能无关紧要。
#footer {
display: flex;
height: 130px;
width: 100%;
background-color: #862d59;
clear: both;
}
#footer, #wrapper:after{
height: 130px;
}
.wrap {
margin: 0 auto;
width: 100%;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.sub {
padding: 12px;
width: 32%;
height: 100px;
color: white;
border-right: solid white 1px;
}
.sub:last-child {
border: 0px;
}
html {
height: 100%;
}
body {
height: 100%;
margin:0;
font-family: courier;
font-size: 22px;
color: white;
}
#wrapper {
position: relative;
margin-left: auto;
margin-right: auto;
width: 85%;
min-height: 100%;
margin-top: -130px;
}
#inner {
position:absolute;
display:flex;
flex-wrap: wrap;
height: 600px;
top:50%;
align-items: center;
justify-content: space-between;
margin-top: -300px;
align-content: center;
width: 100%;
}
#inner p {
background-color: #26004d;
padding: 60px;
border-radius: 9px;
}
#inner img {
border-radius: 8px;
}
<div id="wrapper">
<div id="inner">
<p><img src="cat1.jpeg" alt="Picture of a cat" width="50" height="50"></p>
<p><img src="dog1.jpg" alt="Picture of a cat" width="50" height="50"></p>
<p><img src="park.jpg" alt="Picture of a cat" width="50" height="50"></p>
</div>
</div>
<div id="footer">
<div class="wrap">
<div class="sub"></div>
<div class="sub"></div>
<div class="sub"></div>
</div>
</div>
【问题讨论】:
-
添加您要完成的任务的屏幕截图。目前,它有点不清楚(尤其是看 sn-p)。您还可以使用占位符图像使您的布局在 sn-p 中匹配:placehold.it
-
我想放置文本并将其置于每个 p 元素下方(每个紫色框下方)。所以文本将在紫色之外,但在每个 p 元素下方居中。就像它完全在紫色之外,但在每个盒子的正下方。像这样snag.gy/LtCew1.jpg
标签: html css text flexbox positioning