I need some help with a problem that I think some css can resolve.
I have this nav bar (click in the link), and when I pass the mouse over it and the submenu appear, the content of the nav mix with the content below. Take a look:
enter image description here
I surrounded the local of the problem with red lines.
The correct nav needs to be like this other image:
enter image description here
Realize that the submenu content overlap the textbox below, and it's correct.
My html code is:
<div class="row">
<div class="containerMenu" *ngIf="usuario !== undefined" >
<nav>
<ul class="wrapper" >
<li class="dropdown" *ngFor="let menu of usuario.menus">
{{menu.nmMenu}}
<div class="dropdown-list">
<a routerLink="{{sub.path}}" *ngFor="let sub of menu.subMenus">{{sub.nmMenu}}</a>
</div>
</li>
</ul>
</nav>
</div>
</div>
And my atual CSS :
nav{
text-align: left;
/* background-color:black; */
margin:0 auto;
}
nav ul{
margin:0;
padding:0;
text-align: center;
list-style-type: none;
display: inline-block;
}
nav ul li{
float:left;
min-height:18px;
font-size:12px !important;
display:table-cell;
font-weight:bold;
}
nav a{
display: inline-block;
padding:8px 17px;
color:#fff;
text-decoration: none;
}
.dropdown{
position: relative;
display: inline;
}
.dropdown-list{
display: none;
position: absolute;
background-color:white;
min-width: 180px;
}
.dropdown-list a{
/* color:black; */
text-decoration: none;
display: block;
color:black;
}
.dropdown-list a:hover {
background-color: #F5F5F5;
color:black;
position: absolute;
}
.dropdown:hover .dropdown-list {
display: block;
}
What can I do to the nav sub Itens appear correctly, like the second image?
Thanks in advance!
You should try add to css code z-index: 1;
Related
I am having a hard time aligning the breadcrumbs horizontally.
There is an existing style sheet for the container divs and something in it is preventing the output.
The ul li appear one below the other.
http://jsfiddle.net/y9tyc2cu/1/
HTML:
<div class="chatWrapper">
<div class="chatContainer">
<div class="chatMsgWrapper">
<ul id="crumbs">
<li>Home
</li>
<li>Main section
</li>
<li>Sub section
</li>
<li>Sub sub section
</li>
</ul>
</div>
</div>
</div>
CSS:
ul#crumbs, ul#crumbs li {
list-style-type:none;
padding:0;
margin:0;
}
#crumbs {
height:2.3em;
border:1px solid #dedede;
}
#crumbs li {
float:left;
line-height:2.3em;
color:#777;
padding-left:.75em;
}
#crumbs li a {
/*background:url(/Assets/Images/crumbs.gif) no-repeat right center;*/
background:gray;
padding:5px 15px 5px 0;
}
Here is the solution. float: none; for each li and display: inline; for ul.
Check here!
if you are a bootstrap user you need
you should have bootstrap.min.js
http://getbootstrap.com/2.3.2/components.html#breadcrumbs
<ul class="breadcrumb">
<li>Home <span class="divider">/</span></li>
<li>Library <span class="divider">/</span></li>
<li class="active">Data</li>
</ul>
just add display:inline and remove float: left from li
example
http://jsfiddle.net/y9tyc2cu/3/
You have two redundant styles for the li.
You may remove this style:
.chatContainer ul li{
float: left; clear: both; margin: 10px 0;
width: 100%; padding: 10px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
Also, make the li as display: inline-block or clear the floats properly:
#crumbs li {
display: inline-block;
line-height: 2.3em;
color: #777;
padding-left: .75em;
}
Your updated fiddle: http://jsfiddle.net/abhitalks/y9tyc2cu/2/
Update:
As per your comment, you can't remove or change an existing style. In that case, you need to override the styles which are set in the earlier defined style. Just add these two overrides in #crumbs li style, without changing or removing anything elsewhere:
width: auto; float: none;
So, your complete style now looks like this:L
#crumbs li {
display: inline-block;
line-height: 2.3em;
color: #777;
padding-left: .75em;
width: auto;
float: none;
}
Updated fiddle: http://jsfiddle.net/abhitalks/y9tyc2cu/6/
.
I have some mysterious white space that I don't know how to get rid of. I have a vertical list and I want it to be right next to the paragraph with text. Here is my HTML and CSS
SOLVED BY jmgem I ALSO HAD TO READJUST THE SIZE OF MY PARAGRAPH ELEMENT SO IT WOULD FIT BESIDE THE NAV BAR
HTML
<div id="classOfferingList" class="classOfferingList" align="left">
<ul>
<li>
<a href="" >General U.S. K-12 English Speaking Course</a>
</li>
<li>
<a href="" >University Preperation Course</a>
</li>
<li>
<a href="" >SAT Preperation Course</a>
</li>
<li>
<a href="" >GRE Preperation Course</a>
</li>
</ul>
</div>
<div id="classOfferingInfo" >
<p>example text</p>
</div>
CSS
.classOfferingList ul {
list-style-type: none;
float: left;
}
.classOfferingList ul li {
margin: 5px 0px;
}
.classOfferingList ul li a {
list-style: none;
margin: 1px 0px;
display: inline-block;
background-color: blue;
width: 35%;
text-align: center;
}
First of all, I copied your code into jsfiddle. Go on in and have a look.
http://jsfiddle.net/GyuX5/
If I understand your question correctly, you wanted to put the paragraph right next to the vertical menu. So here's your adjusted CSS
.classOfferingList ul {
list-style-type: none;
float: left;
}
.classOfferingList ul li {
margin: 5px 0px;
}
.classOfferingList ul li a {
list-style: none;
margin: 0px;
display: inline-block;
background-color: grey;
text-align: center;
width: 150px;
}
#classOfferingInfo {
display: inline-block;
}
I had your paragraph display as an inline-block, then I changed the width of the li a to 150px instead of 35%. Voila.
Chose not to use a left float as they tend to disrupt layouts as they become more complicated. try to imagine html/css as blocks filling up a row in the browser from left to right.
Try floating the two main div to the left then they will be right next to each other. See Fiddle
.classOfferingList {
float: left;
}
.classOfferingList ul {
list-style-type: none;
float: left;
}
.classOfferingList ul li {
margin: 5px 0px;
}
#classOfferingInfo {
float: left;
}
.classOfferingList ul li a {
list-style: none;
margin: 1px 0px;
display: inline-block;
background-color: blue;
width: 35%;
text-align: center;
color: #fff;
}
http://jsfiddle.net/erenyener/TC856/
#classOfferingList > ul
{
padding:0px;
}
you need to reset ul element
or your question could be this
FIDDLE
I would like to diplay three horizontal contents. The horizontal contents are following.
1) Logo at the left side. It has been done
2) Menu bar with menus and sub menus with some basic css class.
3) Google map
These three contents should be placed fixed height for all the browsers. So I have set fixed height for these three horizontal div contents. But SubMenu of Menu bar are not showing up. Because, of my fixed div content (which is present in the middle). I dont know how to fix it. Any help is much appreciated. My code are below.
**//Content ONE**
<div id="HeadContainer" style="height: 62px;">
<div id="logoHolder" style="float: left;">
<img src="logo/image.gif" alt="Company Logo" />
</div>
</div>
<hr />**//Content TWO**
<div id="menubar" style="height: 28px;">
<ul class="dropdown">
<li>Draw Region
<ul class="sub_menu">
<li>Add New Region
<ul>
<li>Polygon Tool
</li>
<li>Rectangle Tool
</li>
<li>Circle Tool
</li>
</ul>
</li>
<li>Stop Drawing Region
</li>
</ul>
</li>
<li> Edit Region
</li>
<li>Remove Region
</li>
</ul>
</div>
<hr />**//Content THREE**
<div id="map-canvas" style="height: 400px"></div>
<hr />
CSS I have used for menu bar is following
I have not coded the following. I just copied the script from the net. But it is good nothing problem in it.
ul.dropdown {
position: relative;
}
ul.dropdown li {
font-weight: bold;
float: left;
zoom: 1;
background: #ccc;
}
ul.dropdown a:hover {
color: #000;
}
ul.dropdown a:active {
color: #ffa500;
}
ul.dropdown li a {
display: block;
padding: 4px 8px;
border-right: 1px solid #333;
color: #222;
}
ul.dropdown li:last-child a {
border-right: none;
}
/* Doesn't work in IE */
ul.dropdown li.hover, ul.dropdown li:hover {
background: #F3D673;
color: black;
position: relative;
}
ul.dropdown li.hover a {
color: black;
}
/*
LEVEL TWO
*/
ul.dropdown ul {
width: 220px;
visibility: hidden;
position: absolute;
top: 100%;
left: 0;
}
ul.dropdown ul li {
font-weight: normal;
background: #f6f6f6;
color: #000;
border-bottom: 1px solid #ccc;
float: none;
}
/* IE 6 & 7 Needs Inline Block */
ul.dropdown ul li a {
border-right: none;
width: 100%;
display: inline-block;
}
/*
LEVEL THREE
*/
ul.dropdown ul ul {
left: 100%;
top: 0;
}
ul.dropdown li:hover > ul {
visibility: visible;
}
The submenu is hidden behind the map, add z-index: 100 to ul.dropdown ul, and it should be in front of it. Check the demo.
i am trying to center my css navigation bar but cant figure out why is not working, where am i doing wrong. i want it in the top center of the page.
i tried margin:0 auto but it wont work
here is my code:
<style>
ul {
list-style-type: none;
padding: 0;
overflow:hidden;
}
a:link,a:visited {
margin:0 auto;
display:block;
width: 120px;
font-weight:bold;
color:#FFFFFF;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover, a:active {
background-color:#7A991A;
}
li {
float: left;
}
#menu {
background-color:#98bf21;
}
</style>
<div id="menu">
<header>
<ul>
<li>Home</li>
<li>News</li>
<li>Articles</li>
<li>Forum</li>
<li>Contact</li>
<li>About</li>
</ul>
</header>
</div>
Change your last two CSS rules to:
li {
display:inline-block;
}
#menu {
background-color:#98bf21;
text-align:center;
}
jsFiddle example
margin: 0 auto; only works on items that have defined widths. However, the way you currently have it written, each a tag is attempting to center, when you really want to center the ul. Here is a great way to center that when you don't know the width of your ul. Use these styles in your header, ul and li elements. Add styling to your a tags to suit.
header {
float: left;
width: 100%;
overflow: hidden;
position: relative;
}
ul {
float: left;
list-style: none;
position: relative;
left: 50%;
}
li {
display: block;
float: left;
position: relative;
right: 50%;
}
What's going on here is we're setting the header to full width, and then pushing the ul half way across the width of the browser. Then we push the li's back half the width of the ul, which now centers them on the page.
Here is a link with a very helpful tutorial about doing this very thing: http://matthewjamestaylor.com/blog/beautiful-css-centered-menus-no-hacks-full-cross-browser-support
Good luck!
Use the inline-block css magic :)
JSFiddle
li {
display: inline-block;
}
#menu {
background-color:#98bf21;
margin: 0 auto;
text-align: center;
width: 80%;
}
I had the same problem until I read this post and decided to center the text in the "nav".
So basically your ul should be in a nav so you can text-align: center the nav area.
nav {
width: 75%;
margin: auto
}
#menu {background-color: #98bf21}
.container{padding: 0.10em}
.cell-row {display:table; width:100%}
.cell {display: table-cell}
.cell-middle {vertical-align: middle}
a:link, a:visited {
font-weight: bold;
color: black;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
}
a:hover, a:active {background-color: #7A991A}
#media (max-width: 500px) {
.mobile {
display: block;
width: 100%;
text-align: center
}
nav {
width: 100%;
margin: auto
}
}
<nav>
<div id="menu" class="cell-row" style="text-align: center">
<div class="container cell cell-middle mobile">Home</div>
<div class="container cell cell-middle mobile">News</div>
<div class="container cell cell-middle mobile">Articles</div>
<div class="container cell cell-middle mobile">Forum</div>
<div class="container cell cell-middle mobile">Contact</div>
<div class="container cell cell-middle mobile">About</div>
</div>
</nav>
Add the following css:
ul {
margin: 0 auto;
display: inline-block;
}
This will make the ul fit its contents and then be centered in its container.
I am trying to create a mega menu like those at http://rackspace.com. I have tried the tutorials given at some of the other questions about this already asked, but one of them used a lot of images, and one of them didn't work with the version of jQuery they linked to. I would like to keep this all CSS, but if I must I could use some JavaScript.
I don't understand how to make complex mega menu's but only the simple drop-down's. If someone could provide me with the code for this I would be very happy. I am learning CSS now and I think this will allow me to sharpen my knowledge as well.
Thanks,
Scott
Here is a very nice looking solution a quick Google search turned up. Haven't tried it myself but looks promising: http://net.tutsplus.com/tutorials/html-css-techniques/how-to-build-a-kick-butt-css3-mega-drop-down-menu/
Your question is too general. What you're trying to achieve is not going to happen with a simple HTML and CSS code that we can write here.
So you may be interested in this this jQuery plugin and CSS framework:
https://myflashlabs.github.io/24component-bars/
It helps you to create responsive mega menu, header, sidebar, and footer with lots functionalities fast and easy, without any hassle... It's exactly what you want :)
You don't need to code it yourself all from the beginning when there's already a solution out there!
Extremely quick sample of what you need to do:
http://jsfiddle.net/KqZd4/
I know this looks nothing like those, but that really is all the functionality you need. Just expand what is in the dropdown
<li class="main_list">Electronics
<ul>
<p class="category_header">Buy Any Electronics Item And Get Flat 50% OFF</p>
<ol>
<li>Mobiles</li>
<li>Item1</li>
<li>Item2</li>
</ol>
<ol>
<li>Tablets</li>
<li>Item1</li>
<li>Item2</li>
</ol>
</ul>
</li>
add more you want
then simple style
#main_menu
{
background-color:#1C1C1C;
float:left;
padding:0px;
width:700px;
height:50px;
line-height:50px;
margin-left:140px;
border-radius:5px;
}
#main_menu .main_list
{
color:white;
list-style-type:none;
float:left;
border-left:1px solid #666;
padding-left:27px;
padding-right:27px;
}
#main_menu .main_list:hover
{
color:#2E9AFE;
}
.main_list ul
{
background-color:white;
width:600px;
position:absolute;
left:150px;
width:700px;
padding:0px;
float:left;
padding-bottom:10px;
}
.main_list ul p
{
color:white;
background-color:#2E9AFE;
margin:0px;
text-align:left;
padding-left:10px;
font-size:20px;
font-weight:bold;
}
.main_list ul ol
{
float:left;
padding:0px;
list-style-type:none;
margin-left:30px;
}
.main_list ul ol li
{
line-height:25px;
font-weight:bold;
font-size:16px;
color:#2E9AFE;
}
if you have any problem understanding here is a complete tutorial
http://talkerscode.com/webtricks/mega-dropdown-menu-like-ecommerce-using-css.php
Try This
#import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
* {
box-sizing: border-box;
font-family: sans-serif;
}
body {
margin: 0;
}
/* Style Navigation bar */
.navbar {
display: -webkit-flex;
display: flex;
background-color: #e3e3e3;
}
.navbar a {
display: block;
text-decoration: none;
color: black;
padding: 1.1em 1em;
font-size: 1.1em;
border-bottom: 3px solid transparent;
transition: 0.1s;
}
.navbar > a:hover, .dropdown > a:hover {
border-bottom-color: #FA7D19;
}
/* Style Mega Menu */
.dropdown-content {
display: none;
position: absolute;
width: 90%;
left: 5%;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
overflow: hidden;
}
.dropdown-content .header {
padding: 16px;
color: #777;
background: white;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* Create three equal columns that stacks next to each other */
.row {
display: -webkit-flex;
display: flex;
}
.column {
width: 100%;
padding: 10px;
background: #f8f8f8;
}
.column a {
color: black;
padding: 16px;
text-decoration: none;
display: block;
text-align: left;
}
.column a:hover {
background-color: #ddd;
}
/* Makes the three columns stack on top of each other instead of
next to each other (when screen width is 600px or less) */
#media screen and (max-width: 600px) {
.row {
flex-direction: column;
}
}
<div class="navbar">
Home
<div class="dropdown">
Dropdown <i class="fa fa-caret-down"></i>
<div class="dropdown-content">
<div class="header">
<h2>Mega Menu</h2>
</div>
<div class="row">
<div class="column">
<h3>Category 1</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 2</h3>
Link 1
Link 2
Link 3
</div>
<div class="column">
<h3>Category 3</h3>
Link 1
Link 2
Link 3
</div>
</div>
</div>
</div>
Pricing
</div>
<div style="padding:10px 15px;">
<h1>Create a Mega Menu</h1>
<p>Hover over the "Dropdown" link to see the mega menu.</p>
</div>
Reference:How To Create a Mega Menu