Top Sticky Bar

Sticky bar at the top

by jshacker

HTML

<div class="top fixed bar switcheroo init-dark unselectable">
  <div class="left float">
    <div class="item clickable unselectable">Item A</div>
    <div class="item clickable unselectable">Item B</div>
    <div class="item clickable unselectable">Item C</div>
  </div>
  <div class="right float">
    <div class="item clickable unselectable">Item D</div>
    <div class="item clickable unselectable">Item E</div>
  </div>


</div>

<div id="mainContainer">

  <p class="switcheroo init-dark">
    I am a switcheroo init-dark.
    <span class="item">I am an item.</span>
  </p>

</div>

CSS

.bar.fixed {
  position: fixed;
  width: 100%;
  /* Because fixed items expand only as much as their content. */
  min-width: 550px;
}

.top {
  top: 0;
}

.bar {
  padding: 10px;
  display: inline-block;
}

.bar .left,
.bar .right {
  display: inline-block;
}

.bar .left.float {
  float: left;
  margin-left: 20px;
}

.bar .right.float {
  float: right;
  margin-right: 20px;
}

.float::after {
  clear: both;
  content: ' ';
  display: table;
}

.bar .item {
  display: inline-block;
  padding: 10px;
  margin: auto 10px;
}

.switcheroo.init-dark {
  background-color: #333;
  color: #FFF;
}

.switcheroo.init-dark .item {
  background-color: #CCC;
  color: #000;
}

.switcheroo.init-dark .item:hover {
  background-color: #333;
  color: #FFF;
}

.switcheroo.init-dark .item:hover {
  outline: thin solid #FFF;
}

.clickable:active {
  transform: translateY(2px);
}

.clickable {
  cursor: pointer;
}

#mainContainer {
  position: relative;
  top: 80px;
}

.unselectable {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}