html - 几乎垂直居中对齐

标签 html css

考虑以下 HTML:

<div class="plaisio">
   <div id="phone">
     <img src="img/phone.png" >
   </div>  
   <div id="phone_num">
     <img src="img/phone_num.png" >
   </div>
 </div>

及其响应的 CSS:

.plaisio{
overflow: auto;
max-width:320px;
line-height:100px;
margin-top: 25px;
background-color: #333333;
background-image: -ms-linear-gradient(center top , #333333, #000000);
background-image: -moz-linear-gradient(center top , #333333, #000000);
background-image: -webkit-linear-gradient(center top , #333333, #000000);   
}
.plaisio img{
vertical-align:middle;
}
#phone{
float:left;
    width:20%;
margin-left:5%;
margin-right:8%;
}
#phone_num{ 
float: left;
width:65%;
margin-right:2%;
}

您可以在 http://users.sch.gr/ellhn 看到它的直播.查看页脚处的电话图像和电话号码。我的问题是为什么两张图片(phone.png 和 phone_num.png)几乎而不是完全垂直对齐。如果仔细检查页面,您会发现这两张图片最靠近 .plaisio 的底部,而不是人们所期望的位于中间!

谢谢

最佳答案

dispay inline-block #phone#phone_num , no float并且 vertical-align 它们相互对齐。

您可以将图像设置为 display :blockvertical-align:topbottom 以消除 下方留下的空白(字母 j、q、p、y 所使用的间隙)

关于html - 几乎垂直居中对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23167986/

相关文章:

html - Bootstrap Center 表单和 Logo ,如响应式搜索引擎

html - 无论浏览器的字体如何,如何拥有固定的字体大小?

html - CSS 悬停效果改变其他地方的文本样式

javascript - 如何使这个 svg 圆圈可点击

html - MVC HTML 编辑器

html - 向下移动 anchor 标签?

python - 如何在 HTTP 响应中返回 HTML 文件(Azure-Functions)

javascript - Liferay 6.0.6 plugin SDK生成的骨架portlet工程中main.js和main.css应该如何使用?

css - IE 中不需要的 (img) 侧边距

css - 有什么方法可以使用 headless Chrome 录制网站视频吗?