JSFIDDLE DEMO
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li>
1
</li>
<li class="active arrow_box">
2
</li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-3 col-md-10 col-md-offset-2 main">
Example content with tabs at top
</div>
</div>
</div>
CSS
.sidebar {
display: none; }
#media (min-width: 50em) {
.sidebar {
position: fixed;
top: 30px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px 0;
margin-right: 20px;
overflow: hidden;
background-color: #E5E5E5; } }
.nav-sidebar > li > a {
color: #262626;
font-size: 16pxpx;
padding: 24px 20px 24px 50px; }
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
color: #30C4A3;
background-color: #333;
}
.nav-sidebar > li.active a:after {
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid re;
position: absolute;
bottom: -13px;
width: 0px;
left: 0;
margin-left: -10px;
z-index: 90000; }
.main {
overflow: hidden;
max-width: 1024px;
padding: 10px 0;
z-index: 0; }
#media (min-width: 50em) {
.main {
padding-right: 40px;
padding-left: 40px; }
}
.arrow_box {
background: #595959;
}
.arrow_box:after {
left: 100%;
top: 70%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(89, 89, 89, 0);
border-left-color: #595959;
border-width: 15px;
margin-top: -30px;
z-index: 4000;
}
Used Bootstrap Dashboard template example.
Tried omitting overflow-x but the scroll appeared and arrow could be only seen when scroll right. Tried adding padding or margin to give extra space next to li to display arrow, but the arrow still hid behind the main div. Also tried add z-index to header, sidebar, main but also not helping.
Updated
Forgot to clarify that the arrow I have got is only on sidebar. It should be outside the sidebar which is at the left side of content div. That's why I am trying to get arrow visible on the main div and it ends up being hidden.
Please help.
Just remove overflow: hidden; from .sidebar
Example here http://jsfiddle.net/u2Lbx4kc/3/
.sidebar {
position: fixed;
top: 30px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px 0;
margin-right: 20px;
background-color: #E5E5E5;
}
I didn't completely get your question but when the min-width is removed the li with class arrow seem to appear http://jsfiddle.net/u2Lbx4kc/1/
Add classes to ul to give it a width
HTML
<ul class="nav nav-sidebar col-sm-12 col-md-12">
<li> 1
</li>
<li class="active arrow_box"> 2
</li>
</ul>
Fiddle
Related
My problem is when I scroll up, the text on the page goes through my navbar and it looks really unprofessional and I need to fix it. I want to make it so that my navigation bar is layered on top of my body / section text (body text includes navigation bar but section only includes text not on my nav bar),
I tried adding a background-color and that worked except when I used my dark / light mode switcher, I have css properties for dark mode and light mode but I can't use a background color otherwise when you switch, it will still show the background color for light mode (or whatever mode you were deigning for).
I also tried Z-Indexes since that is supposed to work but no, literally did nothing. Which was really weird. I wish I could elaborate more but that's all I can say, it just didn't work. Here is an example of what I did but I can't actually show you the exact code since I already deleted those Z-Indexes since they didn't work.
EXAMPLE NAV BAR CSS {
z-index: 100;
}
EXAMPLE SECTION / TEXT CSS {
z-index: -100;
}
Here's my navigation bar code:
<ul>
<div class="without-dark-ul">
<img class="logo" width="100px" src="\imgs\logo.png">
<h1 class="logo-side">[PRIVATE] Accounting</h1>
<h2 class="logo-side-slogan">The best, afforadable accounting.</h2>
<br>
<hr>
<h3 class="navbar-text">Navigation</h3>
<div class="navbar">
<li><a class="main-nav" href="#">Home</a></li>
<li>Pricing</li>
<li>Contact</li>
</div>
<div class="vl"></div>
<h3 class="dark-mode-text">Dark / Light Mode</h3>
</div>
<div class="ul-dark">
<li class="li-dark">
<span>Dark</span>
<span>Light</span>
</li>
</div>
</ul>
And here's my CSS for my navbar (and I've got some in navbar CSS and some in dark mode CSS, I honestly don't know why I did it like that though.)
/* START NAVBAR */
.logo-side {
margin-left: 140px;
margin-top: -95px;
font-size: 40px
font-
}
.logo-side-slogan {
margin-left: 140px;
margin-top: -30px;
}
.logo {
margin-top: 20px;
margin-left: 20px;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
position: fixed;
/* position: -webkit-sticky; Safari */
/* position: sticky; */
top: 0;
width: 100%;
z-index: 100;
}
ul > hr {
margin-left: 10px;
margin-right: 10px;
margin-top: -10px;
}
li {
float: left;
}
li a {
display: block;
text-align: center;
padding: 14px 16px;
text-decoration: none;
color: inherit;
}
li a:hover {
background-color: rgb(105, 103, 103);
}
.main-nav {
background-color: #383838;
color: white;
}
.navbar {
margin-left: 20px;
margin-top: 30px;
padding-bottom: 70px;
}
.navbar-text {
margin-left: 20px;
margin-bottom: -20px;
}
.navigation-bar {
background-color: #262626;
position: absolute;
}
/* END NAVBAR */
/* START DARK MODE */ (This includes some nav bar CSS properties.)
.li-dark {
list-style: none;
width: 100%;
height: 60px;
text-align: center;
text-transform: uppercase;
transition: 0.5s;
}
.ul-dark.active li {
transform: translateY(-30px);
}
ul li span {
display: block;
height: 30px;
line-height: 30px;
width: 100%;
}
ul li span:nth-child(1) {
background: #262626;
color: #fff;
}
.ul-dark {
position: static;
top: 20px;
right: 20px;
margin-top: 25px;
margin-left: 320px;
padding: 0;
width: 100px;
height: 30px;
border: 1px solid #000;
cursor: pointer;
overflow: hidden;
}
.dark-mode-text {
margin-left: 320px;
margin-top: -113px;
}
/* END DARK MODE */
I don't know if that is all you need but please ask me to send more code if you need more!
Thanks for your help.
Solninja A
give a position relative to body and your text parent
and z-index:10000;
I have been working to make a multi-level dropdown navbar, and when the dropdown finally started working, the rest of the navigation broke.
I'm trying to get a navbar with a width of 100% of the body, and then a container that is 80% of the body
#nav {
width: 100%;
background-color: red;
}
.container {
width: 80%;
}
However, after getting the dropdown to work, the background color of the nav (red) is no longer showing, and the grey area of the dropdown lists only spans across a much smaller area.
How can I get the dropdown/navigation lists to sit within the container (80% of body) while keeping the span all the way across the 100% width of the body? Note, the colors don't matter so much right now, just getting the right distance setup.
Here is a CodePen
And the snippet
#nav {
width: 100%;
background-color: red;
}
.container {
width: 80%;
}
.third-level-menu {
position: absolute;
top: 0;
right: -150px;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li {
height: auto;
background: #999999;
}
.third-level-menu > li:hover {
background: #cccccc;
}
.second-level-menu {
z-index: 2;
position: absolute;
top: 30px;
left: 0;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.second-level-menu > li {
position: relative;
height: 30px;
background: #999999;
}
.second-level-menu > li:hover {
background: #cccccc;
}
.top-level-menu {
list-style: none;
padding: 0;
margin: 0;
z-index: 2;
float: left;
line-height: normal;
text-align: center;
height: auto;
}
.top-level-menu > li {
display: inline-block;
position: relative;
float: left;
height: 30px;
width: 100px;
background: #999999;
}
.top-level-menu > li:hover {
background: #cccccc;
}
.top-level-menu li:hover > ul {
display: inline;
}
.top-level-menu a {
font: bold 14px Arial, Helvetica, sans-serif;
color: #ffffff;
text-decoration: none;
padding: 0 0 0 10px;
display: block;
line-height: 30px;
}
.top-level-menu a:hover {
color: #000000;
}
<nav id="nav">
<div class="container">
<ul class="top-level-menu">
<li>About</li>
<li>Services</li>
<li>
Offices
<ul class="second-level-menu">
<li>Chicago</li>
<li>Los Angeles</li>
<li>
New York
<ul class="third-level-menu">
<li>Information</li>
<li>Book a Meeting</li>
<li>Testimonials</li>
<li>Jobs</li>
</ul>
</li>
<li>Seattle</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div>
</nav>
Change your CSS to look like this:
#nav{
position: absolute;
top: 0px;
left: 0px; // setting left and right to 0px will make the container take up the entire page
right: 0px;
background-color: red;
}
Also, if you want your elements in the navbar centred, add the following lines of code to your current stylesheet.
.container{
margin: 0 auto; // center the container
}
.top-level-menu{
width: 100%; // make the width of the menu 100% of the container
}
.top-level-menu li{
width: 25%; // make the width of each li element 25% of the container (100% / 4 li = 25%)
}
you need to clear float
.clearfix::after {
content: "";
clear: both;
display: table;
}
add clearfix class to top-level-menu
Is it possible to achieve something like above image?
So far I have tried following Code.
.greyParent {
height: 19px;
border-radius: 7px;
background: rgb(196, 196, 196);
}
.greyParent > .activeSlide {
background: rgb(0, 97, 188);
border-radius: 7px;
border-right: 1px solid #fff;
float: left;
width: 20%;
height: 19px;
position: absolute;
}
.greyParent > .activeSlide:first-child {
left: 0%;
z-index: 5;
}
.greyParent > .activeSlide + .activeSlide {
left: 16%;
z-index: 4;
}
<div class="col-xs-4 col-sm-2 col-md-2">
<span class="slideNo">1/5</span>
</div>
<div class="col-xs-8 col-sm-10 col-xs-9 progressImage">
<div class="greyParent">
<div class="activeSlide">
</div>
<div class="activeSlide">
</div>
</div>
</div>
I need to append .activeSlide div tag depending upon tab. Problem I am facing is as I append 5 .activeSlide div tags for fifth slide its not occupying entire parent div tag i.e div.greyParent. I understand that since i am doing position absolute and trying to move divs towards right, This is happening. But since i need to highlight the border of each partition i had to use position absolute. Can someone help me on this? Is there any solution for this?
You can use :before and :after pseudo elements to create this shape.
Draw circle of equal width and height on left/right corners of each list item respectively.
Add box-shadow of 1px or 2px to create border-effect between cells.
Output Image:
* {box-sizing: border-box;}
ul {
display: flex;
list-style: none;
padding: 0;
margin: 20px;
}
ul li {
position: relative;
background: gray;
height: 16px;
width: 60px;
}
ul li:before,
ul li:after {
box-shadow: 2px 0 0 #fff;
border-radius: 100%;
position: absolute;
background: gray;
height: 16px;
content: '';
width: 16px;
left: -8px;
top: 0;
}
ul li:first-child:before {
box-shadow: none;
}
ul li:after {
right: -8px;
left: auto;
}
ul li.active,
ul li.active:before,
ul li.active:after {
background: blue;
z-index: 1;
}
<ul>
<li class="active"></li>
<li class="active"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
You can simply overlap the elements and give them the right width to make sure that they will be in the right place. You should also play with the left property to make them appear where you want.
The key should be in the properties you can see here:
.greyParent > div{
width: 25%;
}
.greyParent > div:nth-child(1){
left:0%;
width: 20%;
}
.greyParent > div:nth-child(2){
left:15%;
}
I have created this small jsfiddle which you can see as an example of what I mean
Try this, it's good ))
<div class="container">
<div class="title">
1/5
</div>
<div class="progress">
<span class="active"></span><span class="active"></span><span></span><span></span><span></span>
</div>
</div>
.container {
display: flex;
}
.container .title {
padding-right: 20px;
}
.container .progress {
display: flex;
width: 250px;
}
.container .progress span {
display: block;
height: 15px;
width: 20%;
background: gray;
border: solid 1px #fff;
border-radius: 7px;
margin-right: -15px;
}
.container .progress span.active {
background: blue;
}
.container .progress span:nth-child(1) {
z-index: 40;
}
.container .progress span:nth-child(2) {
z-index: 35;
}
.container .progress span:nth-child(3) {
z-index: 25;
}
.container .progress span:nth-child(4) {
z-index: 10;
}
JSfiddle example https://jsfiddle.net/5ph3uk94/
Why don't you just use 2 blue elements and 3 grey elements, instead of one big grey parent ?
<div class="col-xs-4 col-sm-2 col-md-2">
<span class="slideNo">1/5</span>
</div>
<div class="col-xs-8 col-sm-10 col-xs-9 progressImage">
<div class="parent">
<div class="activeSlide"></div>
<div class="activeSlide"></div>
<div class="diabledSlide"></div>
<div class="diabledSlide"></div>
<div class="diabledSlide"></div>
</div>
</div>
When the screen is below 450px the logo disappears to give the nav space, but the nav then goes about 20px off the left side of the screen.
http://codepen.io/briligg/pen/emwXaw?editors=110
I believe this is the relevant code - i might have included more than necessary. CSS:
#media screen and (max-width: 450px) {
img#logo {
display: none;
width: 0;
}
nav {
width: 100%;
min-width: 100%;
}
}
div#top{
position: fixed;
top: 0px;
width: 100%;
height: 130px;
z-index: 5;
}
img#logo {
border: 0;
float: left;
width: 20%;
margin-right: 2%;
margin-left: 2%;
margin-top: 5px;
max-width: 123px;
}
nav { position: fixed;
top: 0px;
right: 0px;
width: 70%;
float: right;
padding: 2%;
height: 60px;
max-height: 60px;
margin: 5px 5px;
}
nav button {
padding: 0 4px;
height: 28px;
font: 16px;
}
nav button ul {
position: relative;
display: none;
}
nav button:hover ul, nav button:focus ul {
display: block;
z-index: 6;
list-style: none;
padding: 4px;
}
nav button:hover li, nav button:focus li {
padding: 4px;
}
nav a {
text-decoration: none;
color: white;
}
nav a:hover, nav a:focus {
color: #9dab71;
}
And here is the relevant HTML:
<div id="top">
<a href="default.html"><img id="logo" src="http://www.briligg.com/images/briligg-loopless-blue.png"
alt="briligg home" /></a>
<nav>
<button>Purpose</button>
<button>Moon vs Mars
<ul>
<li>Ambiance</li>
<li><a style="border-bottom: 1px solid #666666;" href="moonvsmars.html#communication">Communication</a></li>
<li>There and Back</li>
</ul>
</button>
<button>Being There
<ul>
<li>World Domination</li>
<li>Chickens</li>
<li>Down with Gravity</li>
<li>The Moonstar</li>
</ul>
</button>
</nav>
</div>
You have given the nav element a min-width of 100%... because of the way the box model works, adding padding and margin to that forces the element to be wider than the viewport.
You can fix it by adding box-sizing: border-box; to your nav element. This will force any padding or border to be included as width. See more details here.
I would suggest reading up on how the box model works at w3schools and adjusting your padding and margin accordingly.
I have a footer nav that has a ul and several lis. Currently the nav is stuck to the bottom of the page, with the lis spread evenly across the bottom of the page.
I want to be able to make one of the lis, taller than all of the others. However, when I try to do it now, by increasing the height of that specific li element, it either just raises the entire nav or does not change. Any ideas?
Here is a Fiddle
and my code:
HTML:
<article class="main home">
<img class="heroLogo" src="media/TM-Logo-4.png">
<nav>
<div class="menuIcon"></div>
<ul>
<li>About</li>
<li>Sleep</li>
<li>Test</li>
<li class="current"><div id="tm">CHANGE MY HEIGHT</div></li>
<li>Relax</li>
<li>Play</li>
<li>Party</li>
</ul>
</nav>
</article>
CSS:
nav {
width: 100%;
position: fixed;
left: 0;
bottom: 0;
font-size: .7em;
}
nav ul, nav:hover ul {
display: block;
background-color: transparent;
text-align: center
left: 0;
bottom: 0;
margin: 0 auto;
width: 100%;
padding: 0 auto;
top: auto;
line-height: 2.5em;
background-color: #FBF6F1;
padding: 8px;
}
nav li, .current {
display: inline-block;
width: 12.5%;
padding: 0;
margin: 0;
}
nav li:nth-child(odd) {
border-left-color: #9AD5E6;
border-right-color: #9AD5E6;
border-left-width: 3px;
border-right-width: 3px;
border-left-style: solid;
border-right-style: solid;
}
a {
padding-bottom: 8px;
}
a:hover {
color: #9AD5E6;
border-bottom-width: 3px;
border-bottom-style: solid;
}
.current {
height:2em; /* Doesn't change anything */
}
Right, that's how list items are displayed. You can use other means to reproduce the desired effect, like adding some padding :
nav li.current {
padding-top:2em;
}
http://jsfiddle.net/x3mqgoq4/
Or keep the text vertically aligned...
nav li.current {
padding:2em 0;
position : relative;
top : -2em;
}
http://jsfiddle.net/x3mqgoq4/1/
If for instance the height of the nav is 60px and the current li height height 65
Do something like:
Nav
height: 65px; /* Its original height plus 5 */
Nav Li normal
height: 60px; /* leaving 5px room for height increment */
Nav li current
height: 605px; /* Normal state height plus 5 and there wont be a problem */