css - 水平对齐 HTML 标题元素

标签 css html web

我希望能在这方面得到一些帮助;我的 div 中有 4 个元素。截至目前,它们彼此堆叠,但我希望它们对齐。 #ninesixty 是它们所在的 div。非常感谢 (:

HTML

<header>
    <div id="ninesixty">    
        <h1 id="home_link">HOME</h1>
        <h1 id="projects_link">PROJECTS</h1>
        <img id="logo" src="images/logo.png"/>
        <h1 id="services_link">SERVICES</h1>
        <h1 id="contact_link">CONTACT</h1>
    </div>
</header>

CSS

header
{
background-color:white;
text-align:center;
}

#ninesixty
{
    height:900px;
    width:960px;
    margin-top:40px;
    background-color:white;
    margin: 0 auto;
    text-align:center;
    border-radius:8px;
    display:inline-block;
}

最佳答案

display:inline-block; 添加到所有 h1,img 标记以使它们内联。

h1,img{
   display:inline-block;
}

FIDDLE

关于css - 水平对齐 HTML 标题元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20887702/

相关文章:

html - css 与不同浏览器的兼容性问题

html - CSS z-index 之谜

css - 关于click事件的csstransition效果

javascript - <Div> 中的随机图像来自数组

html - CSS:在英雄图片上方制作 float 导航栏的最佳方式?

html - 相对定位里面的绝对定位

css - 使用 CSS 垂直拆分页面

javascript - 导出到 ui-grid 中的 csv : exporterAllDataFn fires only when we have more than one page

java - 在 Web 应用程序中找不到属性文件

java - 如何登录并进行JAVA抓取?