سؤال

I'm using bootstrap and it just happen that I wanted to create a responsive website that's why push me through to use bootstrap.

What I want to do is something like on the photo. (NOTE: not the entire page but only the sidebar with the icons.) That's exactly what I want on my sidebar. I'd see a lot of templates that kind of look like on the photo (the sidebar) but nothing's really the same as what I want to happen.

Is anybody able to help me please?

sidebarnav

هل كانت مفيدة؟

المحلول

The classic Bootstrap doesn't have a sidebar component included, you should build it yourself.. If you want to start easier, I'll show you a quick example of code.

So, take a loot at the CSS:

    #wrapper {
  padding-left: 250px;
  transition: all 0.4s ease 0s;
}

#sidebar-wrapper {
  margin-left: -250px;
  left: 250px;
  width: 250px;
  background: #000;
  position: fixed;
  height: 100%;
  overflow-y: auto;
  z-index: 1000;
  transition: all 0.4s ease 0s;
}

#page-content-wrapper {
  width: 100%;
}

.sidebar-nav {
  position: absolute;
  top: 0;
  width: 250px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav li {
  line-height: 40px;
  text-indent: 20px;
}

.sidebar-nav li a {
  color: #999999;
  display: block;
  text-decoration: none;
}

.sidebar-nav li a:hover {
  color: #fff;
  background: rgba(255,255,255,0.2);
  text-decoration: none;
}

.sidebar-nav li a:active,
.sidebar-nav li a:focus {
  text-decoration: none;
}

.sidebar-nav > .sidebar-brand {
  height: 65px;
  line-height: 60px;
  font-size: 18px;
}

.sidebar-nav > .sidebar-brand a {
  color: #999999;
}

.sidebar-nav > .sidebar-brand a:hover {
  color: #fff;
  background: none;
}

.content-header {
  height: 65px;
  line-height: 65px;
}

.content-header h1 {
  margin: 0;
  margin-left: 20px;
  line-height: 65px;
  display: inline-block;
}

#menu-toggle {
  display: none;
}

.inset {
  padding: 20px;
}

@media (max-width:767px) {

#wrapper {
  padding-left: 0;
}

#sidebar-wrapper {
  left: 0;
}

#wrapper.active {
  position: relative;
  left: 250px;
}

#wrapper.active #sidebar-wrapper {
  left: 250px;
  width: 250px;
  transition: all 0.4s ease 0s;
}

#menu-toggle {
  display: inline-block;
}

.inset {
  padding: 15px;
}

}

and the HTML part of the sidebar:

<!-- Sidebar -->
    <div id="sidebar-wrapper">
        <ul class="sidebar-nav">
            <li class="sidebar-brand"><a href="#">Start Bootstrap</a>
            </li>
            <li><a href="#">Dashboard</a>
            </li>
            <li><a href="#">Shortcuts</a>
            </li>
            <li><a href="#">Overview</a>
            </li>
            <li><a href="#">Events</a>
            </li>
            <li><a href="#">About</a>
            </li>
            <li><a href="#">Services</a>
            </li>
            <li><a href="#">Contact</a>
            </li>
        </ul>
    </div>

Hope it helps you !

نصائح أخرى

This HTML would be below the top navigation bar where your content body starts.

<div class= "row">
  <div class="col-xs-3">
      <!-- this is your sidebar area -->
      <div class= "container">image </div>
      <div class= "container">heading </div>
   </div>
   <div class= "col-xs-9">
      <!-- this is the rest of your content area -->
   </div>
 </div>

bootstrap does have a built in sidebar

nav-sidebar

there is actually a template on the bootstrap site, obviously to make it look like the one above your going to need customize a fair bit.

if your looking for some extra glyphicons like the above example you could have a look at font-awesome

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top