gpt4 book ai didi

html - 无法将图像居中

转载 作者:太空宇宙 更新时间:2023-11-04 10:55:04 26 4
gpt4 key购买 nike

我无法将图像垂直居中。我已经尝试过此站点上发布的各种其他解决方案,但它们似乎没有用,除非我做错了什么。这是相关的 CSS:

.boxes {
width: 145px;
height: 100%;
background-color: #fff;
color: #fff;
font-family: 'Muli', sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 32px;
text-align: center;
display: inline-block;
position: relative;
border-radius: 10px 10px 10px 10px;
border: 1px solid #0081d6;
margin: 0 2px 12px 12px;
-webkit-box-shadow: 4px 4px 15px 0px rgba(0,0,0,0.81);
-moz-box-shadow: 4px 4px 15px 0px rgba(0,0,0,0.81);
box-shadow: 4px 4px 15px 0px rgba(0,0,0,0.81);
}
.boxes .heading {
width: 145px;
height: 40px;
color: #fff;
background-color: #0081d6;
font-family: 'Muli', sans-serif;
font-size: 17px;
font-weight: 400;
line-height: 20px;
border-radius: 10px 10px 0 0;
border-bottom: 4px solid #00589e;
}
.boxes .heading a {
color: #fff;
font-family: 'Muli', sans-serif;
font-size: 17px;
font-weight: 400;
}
.boxes .image {
width: 145px; height: 140px;
background-color: #fff;
margin:0 auto;
}
.boxes .link {
width: 145px;
background-color: #0081d6;
height: 38px;
line-height: 18px;
border-radius: 0 0 10px 10px;
border-top: 4px solid #00589e;
}
.boxes .link a {
color: #fff;
font-family: 'Muli', sans-serif;
font-size: 14px;
font-weight: 400;
}

这是 HTML:

<div class="boxes">
<div class="heading"><a href="http://bananacomputers.co.uk/index.php?route=product/search&amp;search=CAD" target="_blank"><span>Computer Aided Design</span></a></div>

<div class="image">
<p><img alt="Computer Aided Design" height="83" src="http://bananacomputers.co.uk/image/data/5810 MAIN.jpg" width="145" /></p>
</div>

<div class="link"><a href="http://bananacomputers.co.uk/index.php?route=product/search&amp;search=CAD" target="_blank"><span style="font-size:14px;">Dell Precision Workstations</span></a></div>
</div>

如有任何帮助,我们将不胜感激。谢谢。

最佳答案

一种可能的解决方案是使用display: tabledisplay: table-cell。要尝试这个,请将其添加到您现有的 css 中:

img {
display: block;
}
.image {
display: table;
}
p {
display: table-cell;
vertical-align: middle;
}

关于html - 无法将图像居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34693151/

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