html - 在 div 中居中 h2 - 非常基础

标签 html css text margin text-align

我想将 h2 居中放置在#top 中,但垂直对齐中间不工作相同的自动边距...我不知道该怎么做!

#top {
    display: block;
    position: relative;
    height: 100px;
    background-color: rgba(89,144,222,.6);
}
#top h2{
    text-shadow: 2px 2px black;
    text-align: center;
    color: white;
    font-family:"Impact";
    font-size: 50px;
}

效果是 - enter image description here

最佳答案

设置line-height:100px; vertical-align:middle 在#top 上。

关于html - 在 div 中居中 h2 - 非常基础,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15589785/

相关文章:

javascript - react .js : function not returning CSS when using Map

html - 复选框/单选按钮换行问题

javascript - 在 <div> 标签中显示一定数量的行

android - 如何在android中为TextView的文本设置样式或字体?

html - 使子 Div 整齐地适合父 Div

html - 模态滚动条在 Firefox 和 IE 中不起作用

javascript - jQuery 宽度值错误

java - 读取输入文本文件

javascript - 如何根据屏幕分辨率应用特定样式表?

python - table-striped 类没有给我替代颜色