中心标志和导航栏水平

时间:2017-05-23 23:00:51

标签: html5 image css3 center nav

如何将我的徽标(img)和菜单链接水平居中。我希望徽标位于左侧,菜单位于右侧但水平居中。 这是我的代码!

感谢

Quote.create().issues
   (0.2ms)  BEGIN
  SQL (0.4ms)  INSERT INTO `quotes` (`created_at`, `updated_at`) VALUES ('2017-05-24 00:47:01', '2017-05-24 00:47:01')
   (7.5ms)  COMMIT
ActiveRecord::HasManyThroughSourceAssociationNotFoundError: Could not find the source association(s) "issue" or :issues in model QuoteIssue. Try 'has_many :issues, :through => :quote_issues, :source => <name>'. Is it one of ?

--- CSS ---

<div class="menu-container">
  <div class="logo">
    <a href="#"><img src=https://app.box.com/representation/file_version_186133299510/image_2048/1.png class="logo"></a>
  </div>
    <nav class="menu">
                <a href="#">Branding</a>
                                <a href="#">Logos</a>
                                <a href="#">Illustration</a>
                                <a href="#">Web</a>
                                <a href="#">Poster</a>
                                <a href="#">Letters</a>
                                <a href="#">All</a>
                                <a href="#">About</a>
     </nav>

</div>
<div class="main-intro">
       <h2>Let's create something great together!</h2>
    </div>

https://codepen.io/Randomood/pen/KmJpWX?editors=1100

2 个答案:

答案 0 :(得分:0)

尝试从你的css中移除徽标的高度?

.logo {
  display: inline-block;
  padding: 1em;
  transition: all 0.6s ease;
  -webkit-transition: all 0.6s ease;
}

<强>编辑:

* {
  padding: 0px;
  margin: 0px;
}

.menu-container{
  background-color: gray;
  margin: 30px;
  position: relative;
  padding: 1em;
}

.logo {
  height:10em;
  border: 1px solid red;
  display: inline-block;
  transition: all 0.6s ease;
    -webkit-transition: all 0.6s ease;
}

.menu {
  float: right;
  margin: 4.5em 0em;
  display: inline-block;
  vertical-align: center;
}

答案 1 :(得分:0)

试试这个“菜单容器”

function StoreUserInfo(UserObject)
{
    // parsing JSON string may be unnecessary here
    if (typeof (Storage) !== "undefined") {
        // do something
    } else {
        // do something
    }
}

Codepen