CSS 페이스북 내비게이션바

1 개요[ | ]

CSS facebook navigation bar
CSS 페이스북 내비게이션바, 페이스북 네비게이션바
SCSS 페이스북 내비게이션바
  • 창 너비에 따라 검색창 너비가 유연하게 줄어듦
  • flex로 분할하고, width, max-width, min-width를 적당히 줌

2 SCSS[ | ]

body {
  margin: 0;
  padding: 0;
  font-size: 12px;
}

#gnb {
  background: #359;
  color: #fff;
  height: 42px;
  .core {
    margin: 0 auto;
    max-width: 700px;
    display: flex;
    justify-content: space-between;
  }
  .left {
    display: flex;
    flex: 1 1 auto;
    justify-content: flex-start;
    div {
      float: left;
    }
    .logo {
      padding: 2px 9px;
      font-size: 26px;
    }
    .search {
      background: #fff;
      border: 1px solid #369;
      border-radius: 3px;
      box-sizing: border-box;
      height: 26px;
      margin: 0;
      width: 100%;
      max-width: 300px;
      overflow: hidden;
      padding-left: 5px;
      padding-right: 48px;
      position: relative;
      top: 8px;
      input {
        width: 100%;
        min-width: 80px;
        height: 24px;
        border: 0;
        border-radius: 3px;
        outline: none;
      }
      button {
        float: left;
        width: 50px;
        height: 32px;
        position: absolute;
        top: 0;
        right: 0;
        background: #f6f7f9;
        border: none;
        border-radius: 0 2px 2px 0;
        cursor: pointer;
        outline: none;
        &:after {
          content: "\f002";
          z-index: 1;
          font-family: FontAwesome;
          position: absolute;
          font-size: 1.1em;
          top: 37%;
          left: 50%;
          margin: -.48em -.42em;
        }
      }
    }
  }
  .right {
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-end;
    a {
      text-decoration: none;
      color: #fff;
    }
    .item {
      padding: 12px 0 12px 8px;
      display: inline-block;
      display: flex;
      vertical-align: top;
      font-weight: bold;
      .home {
        padding: 0 9px;
        border-left: 1px solid #348;
      }
    }
    .jewel {
      padding: 5px;
      a {
        color: #123;
        font-size: 22px;
      }
    }
    .toggle {
      padding: 9px 10px 9px 10px;
      a {
        color: #123;
        font-size: 16px;
        text-decoration: none;
        padding: 0 16px;
        border-left: 1px solid #348;
      }
      &::before {
        content: '';
        display: block;
        height: 18px;
        left: -1px;
        position: absolute;
        top: 12px;
        width: 1px;
      }
    }
  }
}

3 HTML[ | ]

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">

<div id="gnb">
  <div class="core">
    <div class="left">
      <div class="logo"><i class="fa fa-facebook-official" aria-hidden="true"></i></div>
      <div class="search">
        <form>
          <button></button>
          <input type="text" placeholder="Search Facebook" style="" />
        </form>

      </div>
    </div>
    <div class="right">
      <div class="item"><a href="#">Jmnote</a></div>
      <div class="item"><a class="home" href="#">Home</a></div>
      <div class="jewel"><a href="#"><i class="fa fa-users" aria-hidden="true"></i></a></div>
      <div class="jewel"><a href="#"><i class="fa fa-comment" aria-hidden="true"></i></a></div>
      <div class="jewel"><a href="#"><i class="fa fa-globe" aria-hidden="true"></i></a></div>
      <div class="toggle"><a href="#"><i class="fa fa-bars" aria-hidden="true"></i> <i class="fa fa-caret-down" aria-hidden="true"></i></a></div>
    </div>
  </div>
</div>

4 실행예시[ | ]

5 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}