我想将 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;
}
效果是 -
最佳答案
设置line-height:100px; vertical-align:middle
在#top 上。
关于html - 在 div 中居中 h2 - 非常基础,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15589785/