html - 我怎样才能使用 div 标签在我的标题上居中放置一个小横幅

标签 html css

我无法将一个小横幅添加到我博客的标题中。我希望它位于中心并且更靠近页眉的按钮。可能可以通过一些样式属性来实现,但我找不到。这是现在的样子 pctechtips.org

<div id="header_add" style="background-color:#000000;height:70px;width:500px;float:center;align:center;">
<a style="color:yellow" href="http://pctechtips.org/contact/"><small>PCtechtips.org</small></a>
<h2 style="color:blue;text-align:center;top-padding:0">Advertise Here!</h2>
</div>

最佳答案

将水平边距设置为自动:

<div id="header_add" style="background-color:#000000;height:70px;width:500px;margin:0 auto;">
<a style="color:yellow" href="http://pctechtips.org/contact/"><small>PCtechtips.org</small></a>
<h2 style="color:blue;text-align:center;top-padding:0">Advertise Here!</h2>
</div>

查看本文中关于自动边距的部分:http://css-tricks.com/almanac/properties/m/margin/

关于html - 我怎样才能使用 div 标签在我的标题上居中放置一个小横幅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22457938/

相关文章:

html - 表元素未占父元素的 100%

html - 如何阻止我的 chrome 扩展注入(inject)按钮样式被覆盖?

html - 在表格单元格内展开单选按钮

html - 设置其背景图片的div大小

javascript - 旋转图标 Bootstrap 3

javascript - 更改html元素背景图像js

javascript - 使用 jquery .height() 隐藏/显示 div

css - 如何在html中设置字体粗细?

css - 选择器中的 SCSS 排除

css - 为什么边距塌陷效果背景图片?