javascript - 如何将图标放在最右侧的标题中?

标签 javascript html css web

您好,我正在制作我的网站。我想知道如何将联系人图标放在标题部分的最右侧。 (相对于阅读创意思维的标题文本。我该怎么做?下面是我的代码。请帮忙。谢谢。

HTML

<body>
   <div class="auto-style1">
   <div id="header">
      Header
      <h1>Creative Mind</h1>
   </div>
   <div id="nav">
      Navigation
      <ul>
         <li><a href="homepage.html">Homepage</a></li>
         <li><a href="tipsandtricks.html">Tips and Tricks</a></li>
         <li><a href="aboutme.html">About me</a></li>
         <li><a href="getintouch.html">Get in Touch</a></li>
      </ul>
   </div>
   <div id="main">Main</div>
   <h3>Contact Information</h3>
   <h3>Phone</h3>
   <p>1-323</p>
   <h3>Email</h3>
   <a href="mailto:jonathan@gmail.com?"><img src=/>gmail</a>
   <h3>Social Networks</h3>
   <a href="https://www.facebook.com/mourning.9"><img src=/></a>
   <div id="footer">
      Footer
      <h3>Creative Mind  Jonathan Mourning</h3>
   </div>
</body>

CSS

@charset "utf-8";
    /* CSS Document */
body {
    background-color: #A6FFFF;
    width: 100%;
}

#header, 
    #main, 
    #footer {
    display: block;
    position: relative;
    float: left;
}

#header,
    #footer {
    height: 15%;
    width: 100%;
}

#header {
    margin-bottom: 2px;
    font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}

#footer {
    margin-top: 2px;
    text-align: right;
    border: 2px;
}

#main {
    position: relative;
    width: 70%;
    height: 100%;
    margin: 0 auto;
    background-color: #FFF;
    float: center;
    text-align: center;
}

#nav {
    list-style: none;
    margin: 0;
    padding: 0;
    text-align: center;
}

#nav li {
    display: inline;
}

#nav a {
    display: inline-block;
    padding: 10px;
}   

最佳答案

例如你可以使用float: right

HTML:

<div id="header">Header
    <a href="/contact" class="contact"><img src="http://lorempixel.com/100/50"></a>
    <h1>Creative Mind</h1>
</div>

CSS:

.contact {
    float: right;
}

JSFiddle

关于javascript - 如何将图标放在最右侧的标题中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19127794/

相关文章:

jquery - 使用 jQuery 生成随机起始索引

javascript - DOM 中的 node.isSameNode(node1) 和 node === node1 有什么区别?

HTML - 表格 - 单元格内的垂直位置文本

javascript - 使用 AngularJS 显示 div

javascript - 将新键/值对添加到 chrome.storage.sync 中的现有键

javascript - 用透明覆盖层覆盖 div

html - 如何让我的响应式设计看起来更大?

css - 特殊页面背景 - 静态、平铺

javascript - AngularUI map 绑定(bind)事件

javascript - Vue.js 去抖动滚动