下面是我的代码在html和css。当前result和我想要的result与红色。
.product-detail-container {
display: flex;
flex-direction: column;
/* width: 97%; */
max-width: 1200px;
align-self: center;
justify-content: center;
margin: 2.5rem 5%;
}
.product-detail-container .path {
font-size: 1.1rem;
font-family: var(--fontCommon);
display: flex;
color: black;
}
.product-detail-container .path a:hover {
text-decoration: underline;
color: black;
}
.product-detail-container .photo {
width: 45%;
}
.product-detail-container .photo img {
width: 100%;
border: 1px black solid;
}
.description {
display: flex;
margin-left: 2rem;
flex-direction: column;
}
<div class="product-detail-container">
<div class="path">
<a class="path" href="/index.html">All products/</a>
<p class="path" id="path-product-title">product-title</p>
</div>
<div style="display: flex; margin-top: 30px; justify-content: center">
<div class="photo" id="product-photo">
<img src="/assets/products/1.jpg" class="photo" />
</div>
<div class="description">
<p class="product-title" id="product-title">product-title</p>
<p class="product-id" id="product-id">product-id</p>
<p
class="product-price"
id="product-price"
style="margin-top: 2vh">
product-price
</p>
</div>
</div>
</div>
我想使路径是"所有产品/巧克力"对齐它下面的照片,但我需要保持所有元素内。产品-细节-容器中心。如何实现?
1条答案
按热度按时间iszxjhcz1#
从内联样式中删除
justify-content: center
修复了path
和product-detail
的对齐方式。一旦完成,就可以在需要的位置对齐<div class="product-detail-container">
。请参阅下面的代码片段。我还在元素中添加了边框,以使其更容易查看。