link to codepen
I'm trying to make it so there is a max-height (or height) set to this very long list, and for the rest to scroll. I was able to easily achieve that with
height:800px;
overflow:scroll;
The Problem I have is that the "#subcategory" items stop displaying on hover when I apply overflow:scroll
Any ideas are greatly appreciated!
Basic HTML Structure
<!-- Start Auto Transport -->
<li id="topCategory">Auto Transport
<ul id="subContainer">
<li id="subCategory">Auto Insurance</li>
<li id="subCategory">Auto Payment</li>
<li id="subCategory">Gas</li>
<li id="subCategory">Parking</li>
<li id="subCategory">Public Transportation</li>
<li id="subCategory">Service Parts</li>
<!-- add new becomes text field, user enters text then it becomes added as category -->
<li class="hideNewCategory">
<a class="mmNewCat" data-number="1" href="#"><i class="icon ion-plus-circled"></i>Add New Category</a>
<input id="mmCat1" class="mmCatInpt" type="text" placeholder="Enter New Category" maxlength="25"></input>
</li>
</ul>
</li>
<!-- End Auto Transport -->
<!-- Start Bills Utilities -->
<li id="topCategory">Bills & Utilities
<ul id="subContainer">
<li id="subCategory">Domain Names</li>
<li id="subCategory">Fraud Protection</li>
<li id="subCategory">Home Phone</li>
<li id="subCategory">Hosting</li>
<li id="subCategory">Mobile Phone</li>
<li id="subCategory">Television</li>
<li id="subCategory">Utilities</li>
<!-- add new becomes text field, user enters text then it becomes added as category -->
<li class="hideNewCategory">
<a class="mmNewCat" data-number="2" href="#"><i class="icon ion-plus-circled"></i>Add New Category</a>
<input id="mmCat2" class="mmCatInpt" type="text" placeholder="Enter New Category" maxlength="25"></input>
</li>
</ul>
</li>
<!-- End Bills Utilities -->
relevant CSS
ul li:hover #topContainer{
display: block;
}
ul li a {
display: block;
color: $blue;
text-decoration: none;
font-family: verdana;
font-size: 14px;
}
#topContainer{
list-style: none;
color: $blue;
width: 260px;
height: auto;
background: $white;
opacity: 0.9;
position: absolute;
z-index: 1000;
height:800px;
overflow:scroll;
}
#topCategory {
float: none;
width: auto;
height: 20px;
text-align: left;
margin-left: 15px;
}
#topCategory a:hover {
color: $white;
background-color: $blue;
}
#topCategory:hover #subContainer {
display: block;
}
#topCategory a {
font-size: 16px;
position: relative;
bottom: 41px;
margin-top: 46px;
margin-left: -15px;
padding: 20px 0 20px 20px;
border-bottom:1px solid $grey-10;
}
#topCategory a:hover {
color: $white;
}
#subContainer {
list-style: none;
color: $blue;
display: none;
font-size: 12px;
min-width: 230px;
width: 150px;
height: auto;
background: $white;
opacity: 0.9;
margin: -107px 0 0 245px; position: absolute;
z-index: 1000;
white-space:nowrap;
}
#subContainer a{
border-bottom:1px solid $grey-10;
margin-top: 41px;
}
#subCategory {
float: none;
width: auto;
height: 20px;
text-align: left;
margin-left: 10px;
}
#subCategory:hover {
background: none;
}
.active {
background: $white;
}
#subCategory {
float: none;
// hover length
width:215px;
// hover length
text-align: left;
height: 25px;
margin-left: 15px;
margin-right: -43px;
}
Subcategory should be a Class name not an Id element, change that and things will look cleaner.
.subcategory {
}
<div class="subcategory"></div>
Related
Im added tab for the image icon , im try to do that when i click the button (active button) after image icon change to be book_hover.png font color is change but image icon not change ,how to replace the image after NavTab active moment
.footer-tab .tooter-nav-tab {
padding: 2rem;
height: 10vh;
width: 100%;
margin-left: 0rem;
background: white;
border-top: 1px solid #c9cfd9;
display: inline;
text-align: center;
}
p.tab-txt {
font-size: 0.7rem;
}
.footer-tab ul {
list-style-type: none;
margin: 0;
padding: 0;
border-top: 1px solid #c9cfd9;
overflow: hidden;
background-color: #ffffff;
}
.footer-tab li {
float: left;
}
.footer-tab .nav-tabs .nav-link.active {
color: white;
background-color: #8bb6f3;
border-color: #ddd #ddd #fff;
}
.footer-tab li a {
display: block;
color: #3f5370;
text-align: center;
padding: 18px 16px;
text-decoration: none;
}
.footer-tab li a:hover {
background-color: #8bb6f3;
color: white;
}
.footer-tab-img :active {
background:url'https://image.ibb.co/ffSy9F/book_hover.png')no-repeat;
color: white;
}
/*footernavtab*/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="footer-tab">
<ul class="nav nav-tabs" role="tablist">
<li class="img-01 w-25"><a href="" class="nav-link"}}
<span class="footer-tab-img active">
<img src="https://image.ibb.co/mOHJbv/book.png" alt="book" border="0">
</span>
<p class="tab-txt">Book</p>
</a>
</li>
</ul>
</div>
Finally i fixed my issue, im used this class footer-tab-img-01 and added separate color image and code crete like this
`span.footer-tab-img-01 { background: url('/Image/users.png') no-repeat; width: 32px; height: 32px; display: block; margin-left:1.2rem; }
.nav-link.active span.footer-tab-img-01 { background: url('/Image/users-hover.png') no-repeat; width: 32px; height: 32px; display: block; margin-left:1.2rem; }`
<div class="footer-tab">
<ul class="nav nav-tabs" role="tablist">
<li class="img-01 w-25"><a href="" class="nav-link"}}
<span class="footer-tab-img-01">
</span>
<p class="tab-txt">Book</p>
</a>
</li>
</ul>
</div>
I'm trying to do a nav menu in a particular style, It needs to be a bunch of square buttons/list items, then when you hover over an item, the background behind the item changes color, a decent height above the item and behind the drop down list, as seen in the image below.
My issue is that Im curious if I'm doing it the most efficient way and also when I hover over the initial item, it is working but then you go to one of the drop down items and the main/parent item disappears into the background.
Code:
body {
background-color: #00aeef;
}
.navBG {
background-color: #fff;
}
nav {
padding-top: 100px;
padding-left: 100px;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
display: inline-block;
text-align: center;
}
li {
display: inline-block;
display: inline;
float: left;
background-color: #00aeef;
border: solid 4px #fff;
width: 150px;
}
li a {
display: block;
padding: 10px 5px;
color: #fff;
text-align: center;
}
li a:hover {
color: #fff;
border: solid 4px #00ee98;
border-top: solid 100px #00ee98;
margin-top: -100px;
}
.droplinks {
position: absolute;
background-color: #00aeef;
min-width: 150px;
display: none;
margin-left: -2px;
}
.droplinks a {
padding: 10px;
display: block;
border: solid 2px #00ee98;
}
.droplinks a:hover {
color: #fff;
}
.dropbutton:hover .droplinks {
display: block;
}
<div class="container-fluid navBG">
<nav>
<ul>
<li>Home
</li>
<li class="dropbutton">Products
<div class="droplinks">
Widgets
Cogs
Gears
</div>
</li>
<li class="dropbutton">
Services
<div class="droplinks">
Handshakes
Winks
Smiles
</div>
</li>
<li>Shop
</li>
<li>Contact
</li>
</ul>
</nav>
</div>
Then on hovering a menu item, it changes to this;
However, when I then go to a sub menu item the top level item messes up as in the example above. Would could be done to resolve this?
take a look at this fiddle,
and here is how you can properly show the sub menu on hovering on menu item:
li:hover .droplinks{
display: block;
}
body {
background-color: #00aeef;
}
.navBG {
background-color: #fff;
}
nav {
text-align:center;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
display: inline-block;
text-align: center;
vertical-align: middle;
}
li {
display: inline-block;
display: inline;
float: left;
background-color: #00aeef;
width: 150px;
position: relative;
}
li a {
display: block;
padding: 10px 5px;
color: #fff;
text-align: center;
border-width: 30px 5px;
border-color: #fff;
border-style: solid;
}
li:hover a {
color: #fff;
border-color:#00ee98;
}
.droplinks {
background-color: #00aeef;
top: 100%;
display: none;
margin-left: 0;
min-width: 150px;
position: absolute;
margin-top: -15px;
}
.droplinks a {
padding: 10px;
display: block;
border-width: 2px 4px;
border-style: solid;
border-color:#00ee98;
}
.droplinks a:hover {
color: #fff;
}
.dropbutton:hover .droplinks {
display: block;
}
<div class="container-fluid navBG">
<nav>
<ul>
<li>Home
</li>
<li class="dropbutton">Products
<div class="droplinks">
Widgets
Cogs
Gears
</div>
</li>
<li class="dropbutton">
Services
<div class="droplinks">
Handshakes
Winks
Smiles
</div>
</li>
<li>Shop
</li>
<li>Contact
</li>
</ul>
</nav>
</div>
I want to create a horizontal main menu for joomla with bootstrap.
The content is being loaded dynamically by joomla. The styling is done via bootstrap and which overrides it in a separate css file.
It needs to collapse properly for smartphones.
Everything should be done without jquery, if possible.
Task 1
The menu needs to display the submenu items in a horizontal line, the beginning of the main menu, on the left side.
It should be displayed on hover over the parent item. I also added a hover on the submenu itself, so that it stays open if you hover over the submenu items.
But the submenu needs to be replaced if you hover over another parent item.
Task 2
On hover over the parent items, the backgorund needs to display a certain color, so that you can see where are you hovering.
Below the box there needs to be a little triangle in the same color.
Problems
The triangle is not being displayed on all the items.
The box with the parent item shifts the text to the left, since it is adding some space, because of the triangle. The triangle is being added with :hover:after and content: ''.
I got the triangle and the box working, if I change the position of the items to relative. But then the sub-menu is being displayed relative to the parent item and not at the beginning of the menu.
How can I fix that? Is there a way to make the box and the triangle relative and the sub-menu absolute to the menu?
Here is the code on codeply.
Preview
Code
HTML:
<div class="col-xs-15 col-sm-9 col-md-12 mainmenu">
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"></button>
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div id="navbar">
<!-- class="nav-collapse collapse" -->
<!-- begin joomla insert main menu -->
<ul class="nav navbar-nav">
<li class="item-101">
Home
</li>
<li class="item-116 deeper parent"><span class="nav-header">Item 1</span>
<ul class="submenu">
<li class="item-151">
SubItem 1
</li>
<li class="item-103">
SubItem 2
</li>
</ul>
</li>
<li class="item-117 deeper parent"><span class="nav-header">Item2</span>
<ul class="submenu">
<li class="item-254 divider">
<span class="separator">SubItem 1</span>
</li>
</ul>
</li>
<li class="item-118"><span class="nav-header">Item 3</span></li>
<li class="item-119 deeper parent"><span class="nav-header">Item 4</span>
<ul class="submenu">
<li class="item-158">
SubItem 1
</li>
<li class="item-169">
SubItem 2
</li>
</ul>
</li>
<li class="item-120">
Item 5
</li>
<li class="item-121"><span class="nav-header">Item 6</span></li>
<li class="item-157">
Item 7
</li>
</ul>
<!-- end joomla insert main menu -->
</div>
</div>
</nav>
</div>
</div>
CSS:
.navbar.navbar-default{
padding-left: 0px;
padding-right: 0px;
margin: 0px;
z-index: 1;
position: absolute;
}
.navbar.navbar-default > div.container-fluid {
/* remove padding */
padding-left: 0px;
padding-right: 0px;
margin: 0px;
}
.mainmenu {
/* remove padding */
padding-left: 0px;
padding-right: 0px;
margin: 0px;
}
ul.nav.navbar-nav {
font-size: 15px;
text-transform: uppercase;
margin-top: 0px;
margin-left: 0px;
}
.submenu {
padding: 0px;
z-index: 1000;
left: 0px;
display: none;
right: 0px;
float: left;
position: absolute;
margin: 0px;
width: 100%;
}
.submenu > li {
list-style: none;
margin: 4px;
margin-right: 4px;
padding: 0px;
white-space: nowrap;
left: 0px;
right: 0px;
float: left !important;
position: relative;
top: 4px;
text-transform: none;
overflow: hidden;
color: #41291c;
}
.submenu > li:first-child {
margin-left: 0px;
padding-left: 0px;
}
.submenu > li:last-child {
margin-right: 0px;
}
.submenu > li > a {
margin: 0px;
color: #41291C;
}
.submenu > li > a:hover {
text-decoration: none;
color: #41291c;
}
.submenu > li > span {
list-style: none;
margin: 0px;
padding: 0px;
}
.nav.navbar-nav > li {
padding-top: 8px;
padding-left: 11px;
padding-right: 11px;
padding-bottom: 4px;
position: static !important;
height: 29px !important;
white-space: nowrap;
float: left;
display: inline-block;
}
.nav.navbar-nav > li:first-child {
padding-left: 0px;
}
.nav.navbar-nav > li:hover {
background-color: #ded6ad;
}
.nav.navbar-nav > li:hover > .submenu {
/* let the menu appear on hover */
display: block;
}
.nav.navbar-nav > li.active > a{
color: #00aad2;
}
.nav.navbar-nav > li > a {
/* including submenus */
font-size: 15px;
text-transform: uppercase;
margin-top: 0px;
padding: 0px;
color: #222;
}
.nav.navbar-nav > li.active > a {
/* current active */
font-size: 15px;
text-transform: uppercase;
background-color: #ffffff;
color: #00aad2;
}
.nav.navbar-nav > li.active > a:hover {
/* current active on hover*/
background-color: #ffffff;
color: #00aad2;
}
.nav-header{
font-size: 15px;
text-transform: uppercase;
line-height: 17px;
box-sizing: border-box;
cursor: pointer;
}
.nav-header:hover > ul.submenu {
display: block !important;
}
.submenu:hover{
display: block;
}
.nav.navbar-nav > li:hover:after {
/* adds the triangle */
z-index: -1;
width: 0;
height: 0;
border-style: solid;
border-width: 5px 3px 0 3px;
border-color: #ded6ad transparent transparent transparent;
bottom: 0px;
left: 50%;
transform: translateX(-50%);
position: relative;
float: left;
margin: 0px !important;
margin-right: -26px;
padding: 0px !important;
box-sizing: border-box;
display: block;
content: "";
}
I am wanting to display <li>'s as squares in a horizontal line, and have nested squares within them positioned at the bottom left and bottom right of the containing square.
____________ ____________
| | | |
|___ ___| |___ ___|
|_x_|__|_y_| |_x_|__|_y_| etc
I tried adding span's to the <li> but wasn't able to position them correctly.
I've gotten closer with a nested <ul> and two <li>'s within the nested <ul> but there is undesired space between the top level squares.
How do I get control of the spacing between the top level <li>'s?
jsFiddle
http://jsfiddle.net/rwone/4Hzp6/
HTML
<ul class="images_list">
<li class="style_one"><img src="http://dummyimage.com/50/ccc/fff&text=1.png">
<ul class="nested"><li class="delete_span"></li><li class="crop_span"></li></ul>
</li>
<li class="style_one"><img src="http://dummyimage.com/50/ccc/fff&text=2.png">
<ul class="nested"><li class="delete_span"></li><li class="crop_span"></li></ul>
</li>
<li class="style_one">
<img src="http://dummyimage.com/50/ccc/fff&text=3.png">
<ul class="nested"><li class="delete_span"></li><li class="crop_span"></li></ul>
</li>
<li class="style_one">
<img src="http://dummyimage.com/50/ccc/fff&text=4.png">
<ul class="nested"><li class="delete_span"></li><li class="crop_span"></li></ul>
</li>
<li class="style_one">
<img src="http://dummyimage.com/50/ccc/fff&text=5.png">
<ul class="nested"><li class="delete_span"></li><li class="crop_span"></li></ul>
</li>
</ul>
CSS
ul.images_list {
list-style: none;
margin: 0px !important;
padding: 0px !important;
}
ul.nested {
margin: 0px !important;
padding: 0px !important;
display: inline;
position: relative;
left: -54px;
}
li.style_one {
position:relative;
display:inline-block;
/*width: 50px;
height:50px*/
}
.delete_span {
width: 15px;
height: 15px;
background: red;
display: inline-block;
}
.crop_span {
width: 15px;
height: 15px;
background: green;
display: inline-block;
position: relative;
left: 20px;
}
It seams that the problem come from user agent stylesheet (on chrome). Chrome is adding a rules This SO question is talking about it.
It suggest to add ul { padding:0 } but that is not working on your case..
But It might get you on the direction.
ul, menu, dir {
display: block;
list-style-type: disc;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 40px;//I guess this one is the problem
}
I have tried to override this rules adding !important but it doesn't work.
This achieves the behaviour of what I wanted, I used div's within <li>'s:
http://jsfiddle.net/rwone/4Hzp6/6/
HTML
<ul class="images_list">
<li class="style_one"><img src="http://dummyimage.com/50/ccc/fff&text=1.png">
<div class="crop_it"></div><div class="delete_it"></div>
</li>
<li class="style_one"><img src="http://dummyimage.com/50/ccc/fff&text=2.png">
<div class="crop_it"></div><div class="delete_it"></div>
</li>
<li class="style_one">
<img src="http://dummyimage.com/50/ccc/fff&text=3.png">
<div class="crop_it"></div><div class="delete_it"></div>
</li>
<li class="style_one">
<img src="http://dummyimage.com/50/ccc/fff&text=4.png">
<div class="crop_it"></div><div class="delete_it"></div>
</li>
<li class="style_one">
<img src="http://dummyimage.com/50/ccc/fff&text=5.png">
<div class="crop_it"></div><div class="delete_it"></div>
</li>
</ul>
CSS
ul.images_list {
list-style: none;
margin: 0px !important;
padding: 0px !important;
}
li.style_one {
display: inline-block;
height: 50px;
margin-left: 15px;
position: relative;
width: 50px;
}
li.style_one:first-child {
margin-left: 0px;
}
.crop_it {
background: none repeat scroll 0 0 #FF0000;
bottom: 0;
display: inline-block;
height: 15px;
left: 0;
position: absolute;
width: 15px;
z-index: 9;
}
.delete_it {
background: none repeat scroll 0 0 #008000;
bottom: 0;
display: inline-block;
height: 15px;
left: 35px;
position: absolute;
width: 15px;
}
Simple just change the class ul.nested position relative to position absolute and little bit changes in left and top or copy paste the code below:
CSS CODE:
ul.images_list {
list-style: none;
margin: 0px !important;
padding: 0px !important;
}
ul.nested {
margin: 0px !important;
padding: 0px !important;
display: inline;
position: absolute;
left: 0px;
top: 34px;
}
li.style_one {
position:relative;
display:inline-block;
/*width: 50px;
height:50px*/
}
.delete_span {
width: 15px;
height: 15px;
background: red;
display: inline-block;
}
.crop_span {
width: 15px;
height: 15px;
background: green;
display: inline-block;
position: relative;
left: 20px;
}
I have following code:
<div class="settingsMenu" style="top: 135px; left: 149px; display: block;">
<ul>
<li class="download" onclick="downTemplate('template1')">Download</li>
<li class="delete" onclick="showConfirmationDialog ($(this))">
Delete
<div class="deleteItemConfirmation">
<div class="confirmationText">Are you sure?</div>
<div class="buttons"><button onclick="deleteTemplate ('template1')">Yes</button> <button onclick="hideConfirmationDialog();">No</button></div>
</div>
</li>
<li class="info">Info</li>
</ul>
</div>
CSS:
.settingsMenu{
position: absolute;
top: 0;
left: 0;
display: none;
background-color: #FFFFFF;
border: 1px solid #b5044a;
border-radius: 5px;
width: 150px;
padding: 10px 0;
margin: 0;
z-index: 200;
}
.settingsMenu ul{
list-style-type: none;
width: 100%;
margin: 0px;
padding: 0;
}
.settingsMenu ul li {
color: #000000;
cursor: pointer;
float: left;
font-size: 14px;
font-weight: normal;
font-family: Arial;
height: 18px;
max-width: 100px;
margin: 5px 20px;
padding: 0;
display: block;
padding-left: 30px;
}
.settingsMenu ul li.edit{
background: url("../img/edit-context-menu-icon.svg") no-repeat scroll center left white;
}
.settingsMenu ul li.delete{
background: url("../img/delete-context-menu-icon.svg") no-repeat scroll center left white;
}
.settingsMenu ul li.info{
background: url("../img/info-context-menu-icon.svg") no-repeat scroll center left white;
}
Problem is: while div.deleteItemConfirmation has "display: none;" everything is displaying correctly, when it`s display property becomes "display: block;" strange space appears before text of
<li>Delete</li>
Try changing
<li class="delete" onclick="showConfirmationDialog ($(this))">
Delete
To
<li class="delete" onclick="showConfirmationDialog ($(this))">Delete
Could this help you out:
<ul>
<li>
one</li><li>
two</li><li>
three</li>
</ul>
or
<ul>
<li>one</li
><li>two</li
><li>three</li>
</ul>
or with comments...
<ul>
<li>one</li><!--
--><li>two</li><!--
--><li>three</li>
</ul>
I took the idea from http://css-tricks.com/fighting-the-space-between-inline-block-elements/ and helped me in a few similar situations.