css - 图像与其他组件不在一条直线上

标签 css image

我知道对齐有时在 html 中很复杂。但这里有一些让我困惑的事情。我有带有文本、按钮和图像的 div,没有其他选项。

<div class="div-filter">

 <input type="text" value="Hladaj"/>
 <input type="submit" value="Hladaj"/>
 <img alt="image" id = "ShowOrHideImage" />     

enter image description here

为什么图像是 cca 5px 高?没有图像,文本和按钮上就没有填充。当我把图像放在那里时......

要清楚:

<style>
.div-filter
{
    background-color:rgb(235, 235, 98);
    width:100%;        
    border-bottom-width: 1px;   
    border-top-width: 1px;  
    border-left-width: 1px;  
    border-right-width: 1px; 
    border-bottom-color: black;   
    border-top-color: black;  
    border-left-color: black;  
    border-right-color: black;  
    border-bottom-style: solid;   
    border-top-style: solid;  
    border-left-style: solid;  
    border-right-style: solid;  
}

我可以用 table 和 tableRow 解决它,但它对我不利。

最佳答案

这是因为图像与字体基线对齐。

您可能想要添加该规则:

.div-filter img {
    vertical-align: bottom;
}

http://jsfiddle.net/QgBcU/

关于css - 图像与其他组件不在一条直线上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13680508/

相关文章:

javascript - 如何选择数组中的多个元素?

html - 标签内容在IE7下显示异常

javascript - 如何使用 Bootstrap 将按钮居中?

java - 获取图像的 JPEG 渲染的内存表示

带水印的PHP图片上传

css - Wordpress.org 博客 - 将特色图片置于帖子顶部的中心位置

java - 如何在 Java Swing 中使用鼠标平移图像

html - 连续 4 张图片,如何在每张图片下居中放置特定文本?

html - 如何使 Bootstrap 4 卡片组每行宽度相同?

java - java的image magick问题