Reputation: 255
I have the following HTML (ASP)
<div class="container-fluid">
<div class="row row-offcanvas row-offcanvas-left">
<!-- sidebar -->
<div class="col-sm-2 col-xs-1 sidebar-offcanvas" id="sidebar" runat="server">
<!-- Added -->
<div class="logo-header">
<img src="Images/logo-small.png" />
</div>
<!-- Added -->
<ul class="nav hidden-xs" id="lg-menu">
<li runat="server" id="Home"><a href="home.aspx"><i class="fa fa-home fa-fw"></i> Home</a></li>
<li runat="server" id="Customers"><a href="customers.aspx"><i class="fa fa-user fa-fw"></i> Customers</a></li>
<li runat="server" id="Reports"><a href="reports.aspx"><i class="fa fa-bar-chart-o fa-fw"></i> Reports</a></li>
<li runat="server" id="AdminPanel"><a href="adminpanel.aspx"><i class="fa fa-dashboard fa-fw"></i> Admin Panel</a></li>
</ul>
<!-- tiny only nav-->
<ul class="nav visible-xs" id="xs-menu">
<li runat="server" id="Li1"><a href="home.aspx"><i class="fa fa-home fa-fw"></i> </a></li>
<li runat="server" id="Li2"><a href="customers.aspx"><i class="fa fa-user fa-fw"></i> </a></li>
<li runat="server" id="Li3"><a href="reports.aspx"><i class="fa fa-bar-chart-o fa-fw"></i> </a></li>
<li runat="server" id="Li4"><a href="adminpanel.aspx"><i class="fa fa-dashboard fa-fw"></i> </a></li>
</ul>
</div>
<!-- /sidebar -->
<!-- main right col -->
<div class="col-sm-10 col-xs-11" id="main">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server" />
</div>
</div><!-- /.row -->
</div>
and this CSS:
/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
}
#sidebar {
padding:0px;
padding-top:15px;
}
#sidebar, #sidebar a {
color: #951013;
padding-left:5px;
}
#sidebar .nav li>a:hover {
color: #951013;
background-color: #f5f5f5;
}
#sidebar .active > a,
#sidebar .active > a:hover,
#sidebar .active > a:focus {
color: #fff;
background-color: #951013;
}
/* adjust the contents on smaller devices */
@media screen and (max-width: 968px) {
.visible-xs{display:block!important;}
.hidden-xs{display:none!important;}
}
As you see i want to increase/override the default max-width to 968px but when i do that and visible-xs (tiny nav) gets visible its width does not change. It still needs to be 767 and then there remain only the glyph icons without the space to the right. How do i make the visible-xs the same as default but on 968px? Thank you
Upvotes: 0
Views: 1514
Reputation: 21663
There are two solutions in my answer:
1) A different code base that avoids using columns so the sidebar isn't reduced as the viewport changes; you can change the width of the sidebar with media queries then and have more control plus the sidebar is fixed so as you scroll through the main content of the page the sidebar is always there. The links have the same idea as far as hiding the text when you're at 968px.
2) Using your existing code, instead of having two separate menus you can use a class to hide the navigation text when you're at 968px.
Solution #1 (New Codebase)
body,
html {
height: 100%;
}
body {
padding-top: 60px;
}
.sidebar-fixed {
margin-top: 60px;
padding-left: 18px;
padding-right: 18px;
position: fixed;
width: 150px;
height: 100%;
top: 0;
left: 0;
background: none;
}
ul.sidebar-list {
list-style: none;
display: inline;
text-align: left;
}
ul.sidebar-list > li {
padding-bottom: 15px;
}
ul.sidebar-list > li > a {
color: #951013;
text-decoration: none;
}
ul.sidebar-list > li > a:hover,
ul.sidebar-list > li > a:focus {
color: #450C0E;
}
.main-content {
margin-left: 150px;
}
@media (max-width: 968px) {
.sidebar-fixed {
width: 85px;
}
.main-content {
margin-left: 85px;
padding: 0;
}
ul.sidebar-list {
text-align: center;
}
.sidebar-fixed li .nav-text {
display: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" src="http://placehold.it/50x20/f00">
</a>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="sidebar-fixed" id="sideNavParent" runat="server">
<div class="logo-header">
<img src="http://placehold.it/50x50/f00/fff?text=Logo" />
</div>
<ul class="sidebar-list">
<li runat="server" id="Home">
<a href="home.aspx"> <i class="fa fa-home fa-fw"></i><span class="nav-text"> Home</span>
</a>
</li>
<li runat="server">
<a href="#"> <i class="fa fa-user fa-fw"></i><span class="nav-text"> Customers</span>
</a>
</li>
<li runat="server">
<a href="#"> <i class="fa fa-bar-chart-o fa-fw"></i><span class="nav-text"> Reports </span>
</a>
</li>
<li runat="server">
<a href="#"> <i class="fa fa-dashboard fa-fw"></i><span class="nav-text"> Admin Panel </span>
</a>
</li>
</ul>
</div>
<div class="main-content">
<div class="container-fluid">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server" />
<div class="alert alert-danger">Bootstrap Sidebar Navigation</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with
the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic
typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.
</p>
</div>
</div>
</div>
Solution #2 (Original Codebase)
body {
padding-top: 60px;
}
#sidebar {
padding: 0px;
padding-top: 15px;
}
#sidebar,
#sidebar a {
color: #951013;
padding-left: 5px;
}
#sidebar .nav li>a:hover {
color: #951013;
background-color: #f5f5f5;
}
#sidebar .active > a,
#sidebar .active > a:hover,
#sidebar .active > a:focus {
color: #fff;
background-color: #951013;
}
@media (max-width: 968px) {
#lg-menu .hidden-item {
display: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="Brand" src="http://placehold.it/50x20">
</a>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row row-offcanvas row-offcanvas-left">
<!-- sidebar -->
<div class="col-sm-2 col-xs-1 sidebar-offcanvas" id="sidebar" runat="server">
<!-- Added -->
<div class="logo-header">
<img src="http://placehold.it/50x50" />
</div>
<!-- Added -->
<ul class="nav" id="lg-menu">
<li runat="server" id="Home"><a href="home.aspx"><i class="fa fa-home fa-fw"></i><span class="hidden-item"> Home</span></a>
</li>
<li runat="server" id="Customers"><a href="customers.aspx"><i class="fa fa-user fa-fw"></i><span class="hidden-item"> Customers</span></a>
</li>
<li runat="server" id="Reports"><a href="reports.aspx"><i class="fa fa-bar-chart-o fa-fw"></i><span class="hidden-item"> Reports</span></a>
</li>
<li runat="server" id="AdminPanel"><a href="adminpanel.aspx"><i class="fa fa-dashboard fa-fw"></i><span class="hidden-item"> Admin Panel</span></a>
</li>
</ul>
</div>
<!-- /sidebar -->
<!-- main right col -->
<div class="col-sm-10 col-xs-11" id="main">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server" />
<div class="well">Well Well</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with
the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic
typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem
Ipsum.</p>
</div>
</div>
<!-- /.row -->
</div>
Upvotes: 1