【问题标题】:Image to the left and Text to the right in navigation bar导航栏中左侧的图像和右侧的文本
【发布时间】:2016-03-11 09:31:34
【问题描述】:

我的网站顶部有一个导航栏。我无法将图像向左对齐,列表项向右对齐。这是我的代码...

      .nav a li {
        color: white;
        font-family: arial;
        font-weight: 600;
        font-size: 12px;
        margin-right: 15px;
        display: inline-block;
        vertical-align: center;
      }
      .nav {
        padding-bottom: 5px;
        padding-top: 5px;
        margin: 0;
        text-align: left;
        vertical-align: center;
      }
      #top {
        background-color: #0052cc;
        height: auto;
      }
      #Homeimage {
        height: 60px;
        width: 60px;
        padding-left: 40px;
        padding-top: 10px;
        display: block;
        text-align: left;
      }
<div id="top">
  <div class="nav">
    <div class="navbar">
      <ul id="navigation">
        <a href="index.html">
          <li>
            <img src="file:///Users/Luke/Documents/STFCYouth/Images/shrewsbury%20logo.png" ; id="Homeimage">
          </li>
        </a>
        <a href="acadmey.html">
          <li>ACADEMY</li>
        </a>
        <a href="youth.html">
          <li>YOUTH</li>
        </a>
        <a href="pre-acadmey.html">
          <li>PRE-ACADEMY</li>
        </a>
        <a href="contact.html">
          <li>CONTACT</li>
        </a>
        <a href="newsEvents.html">
          <li>NEWS AND EVENTS</li>
        </a>
        <a href="sportsScience.html">
          <li>SPORTS SCIENCE</li>
        </a>
        <a href="vacancies.html">
          <li>VACANCIES</li>
        </a>
      </ul>
    </div>
  </div>
</div>

我希望我的图像在左边,列表项在右边,文本垂直对齐,有人可以帮我吗?This is an image I designed on Word, this is my hopeful end point

【问题讨论】:

  • 本网站不是免费的编码服务。请参考this section 了解您可能在本网站上提出的问题类型。
  • 感谢您的建议,非常感谢 Andrei Gheorghiu

标签: html css


【解决方案1】:

将导航链接包装在单独的div 中并使用float:right;

.nav a li {
  color: white;
font-family: arial;
font-weight: 600;
font-size: 12px;
margin-right: 15px;
display: inline-block;
vertical-align: center;
}
.nav {
padding-bottom: 5px;
padding-top: 5px;
margin: 0;
text-align: left;
vertical-align: center;
}
#top {
background-color: #0052cc;
height: auto;
}
#Homeimage {
height: 60px;
width: 60px;
padding-left: 40px;
padding-top: 10px;
display: block;
text-align: left;
}
#navright{
float:right;
margin-top:20px;
}
<div id="top">
<div class="nav">
    <div class="navbar">
    <ul id="nagigation">
        <a href="index.html"><li><img src="file:///Users/Luke/Documents/STFCYouth/Images/shrewsbury%20logo.png"; id="Homeimage"></li></a>
        <div id="navright">
            <a href="acadmey.html"><li>ACADEMY</li></a>
            <a href="youth.html"><li>YOUTH</li></a>
            <a href="pre-acadmey.html"><li>PRE-ACADEMY</li></a>
            <a href="contact.html"><li>CONTACT</li></a>     
            <a href="newsEvents.html"><li>NEWS AND EVENTS</li></a>
            <a href="sportsScience.html"><li>SPORTS SCIENCE</li></a>
            <a href="vacancies.html"><li>VACANCIES</li></a>
        </div>
    </ul>
    </div>
    </div>
</div>

(全屏查看)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-12
    • 2015-09-27
    • 1970-01-01
    • 2019-03-25
    • 2016-10-22
    • 1970-01-01
    • 2020-12-13
    • 2016-05-11
    相关资源
    最近更新 更多