希望我标记的图像足够容易地描述这个问题。包含图像的红色边框数字没有居中,尽管上面的段落居中。这两个元素都在同一个flexbox容器中。看起来这个图形并不服从它的flexbox父对象。
超文本标记语言:
.stepDescriptionContainer {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
border-style: solid;
border-color: aqua;
margin: 0px 0px;
padding: 0px 0px;
}
.stepDescriptionContainer p {
position: relative;
margin: 0em 0em;
padding: 0em 0em;
text-align: center;
font-size: 0.9rem;
--fontOpticalSize: 23; /*Increase with increasing font size 8-144*/
border-style: solid;
}
.stepImageFigure {
position: relative;
display: flex;
flex-direction: column;
margin: 0px 0px;
padding: 0em 0em;
width: 500px;
border-style: solid;
border-color: rgb(255, 17, 0);
}
.stepDescriptionContainer img {
object-fit: contain;
width: 100%;
}
<div class="stepDescriptionContainer">
<div class="triangle"></div>
<p>We begin with carefully selected kiln-dried hardwoods, ensuring a precise 8% moisture content. This critical measure guarantees the stability and longevity of the final piece. Skilled craftsmen painstakingly inspect each plank; imperfections like deadwood in burls and edges are removed, unveiling nuanced details that enrich the final piece. This stage lays the foundation for the impeccable quality that defines our creations.</p>
<figure class="stepImageFigure">
<img src="..\images\Home\WalnutBlueEpoxyResinTable Part1.png" alt="">
</figure>
</div>
一个重要的点,你看不到的是,CSS上面是在一个媒体查询,其中stepImageFigure从position: absolute
到position relative
。但我看不出这会引起什么问题。
我试过显示:网格,以及你能想象到的各种对齐和对齐的组合。重新排列HTML但没有成功,交叉检查所有拼写。花了大约5小时试图找到一个答案或替代。
期望图形居中并根据其flexbox父对象进行定位。
谢谢你的帮助
1条答案
按热度按时间5vf7fwbs1#
如果您添加justify-content:居中和对齐项目:中心,它将被放置到屏幕的中心位置。