html - 如何将内容对齐到顶部

标签 html css

我有下一个fiddle .您可以看到放置的第二个 block 不在顶部。如何解决?

html 是 -

<div id="test1">
    <div id="ct1">
        <img width="100px" height="100px">
        <div id="cct1">
            123123 12312312 3123123123
        </div>
    </div>
    <div id="ct2">
        <img width="100px" height="100px">
        <div id="cct2">
            123123 12312312
        </div>
    </div>
</div>

样式 -

#test1{
    margin-top:300px;
}
#test1>div{
    display:inline-block;
    width:100px;
    height:200px;
}
#test1>div>div{
    height: 100px;
}

最佳答案

尝试使用垂直对齐属性: Demo

#test1>div{
    display:inline-block;
    width:100px;
    height:200px;
    vertical-align:top;
}

关于html - 如何将内容对齐到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31961160/

相关文章:

javascript - 无法从 getElementsByClassName 创建单击事件处理程序

javascript - react : Add highlighted border around selected image

html - Mat-icon 不在其 div 中心

css - 为什么直接定义CSS类不适用?

javascript - d3 我希望隐藏网格线溢出

html - 如何为 HTML select 元素设置默认消息值?

html - 更改导航栏字体

php - 在sql数据库中存储html代码问题

html - 从底部开始调整 css 元素的大小,占父元素的百分比

css - 如何使用 CSS 去除文本下方的下划线