i try to create box e.g link box.. so when i hover mouse on research then menu appears e.g about gjbssr,data collection services etc... but link always appear with this menu and i want when i hover mouse on about gjbssr then link box will be appear
image
code
.navbar {
height: 50px;
padding: 15px;
margin: 0;
position: absolute; /* Ensures that the menu doesn’t affect other elements */
border-right: 1px solid #54879d;
margin-left: 55px;
padding-left:15px;
padding-bottom:15px;
padding-top:0px;
margin-left:25px;
}
.navbar li {
height: auto;
width: 131px; /* Each menu item is 150px wide */
float: left; /* This lines up the menu items horizontally */
text-align: center; /* All text is placed in the center of the box */
list-style: none; /* Removes the default styling (bullets) for the list */
font: normal bold 12px/1.2em Arial, Verdana, Helvetica;
padding: 0;
margin: 0;
background-color: #366b82;
}
.navbar a {
padding: 18px 0; /* Adds a padding on the top and bottom so the text appears centered vertically */
border-left: 1px solid #54879d; /* Creates a border in a slightly lighter shade of blue than the background. Combined with the right border, this creates a nice effect. */
border-right: 1px solid #1f5065; /* Creates a border in a slightly darker shade of blue than the background. Combined with the left border, this creates a nice effect. */
text-decoration: none; /* Removes the default hyperlink styling. */
color: white; /* Text color is white */
display: block;
}
.navbar li:hover, a:hover {background-color: #54879d;}
.navbar li ul {
display: none; /* Hides the drop-down menu */
height: auto;
margin: 0; /* Aligns drop-down box underneath the menu item */
padding: 0; /* Aligns drop-down box underneath the menu item */
}
.navbar li:hover ul {
display: block; /* Displays the drop-down box when the menu item is hovered over */
}
.navbar li ul li {background-color: #54879d;}
.navbar li ul li a {
border-left: 1px solid #1f5065;
border-right: 1px solid #1f5065;
border-top: 1px solid #74a3b7;
border-bottom: 1px solid #1f5065;
}
.navbar li ul li a:hover {background-color: #366b82;}
// i add this css code for link box
.navbar li ul li ul li
{
margin-top:-50px;
margin-left:130px;
display:block;
}
html
<div id="wrap">
<ul class="navbar">
<li>RESEARCH
<ul id="subnavlist">
<li><a id="subcurrent" href="About_gjbssr.html">About GJBSSR</a>
<ul>
<li> <a href="#" >Link</a></li>
</ul></li>
<li>Data Collection Services</li>
<li>Editing & Proof Reading</li>
</ul>
</li>
<li id="active">CONTACT US</li>
</ul>
</div>
any one tell me please?
Try this http://jsfiddle.net/94bws6ab/2/
HTML
<div id="content">
<ul class="a">
<li class="a_a">About
<ul class="b">
<li class="b_b">BOX</li>
</ul>
</li>
</ul>
</div>
CSS
ul{
list-style:none;
}
.b{
display:none;
}
.a_a:hover .b{
margin-top:-15px;
margin-left:20px;
display:block;
}
EDIT OLD
http://jsfiddle.net/h0b8h1ek/
EDIT
Didn't notice it till now, your code went wrong because you used // to begin a comment in css /* is used this is the part that i changed
/*i add this css code for link box*/
That seemed to solve your problem here is the link to the fiddle http://jsfiddle.net/h0b8h1ek/1/
Related
My drop down menu was working when I only had one navigation bar, but now that the tutoring pages of my business became sub pages in a website featuring all my businesses, I made the tutoring navigation bar a subnavbar, and at that point, my drop down menus stopped working. When I hover over "services," "contact me," and "resources," I should see a drop down menu, but I don't, so now there are several pages clients can not access. I do not get why they stopped working, and I have tried to research this, but I feel like I have done everything right...
CSS CODE
**/* 1st Navigation Bar */**
#nav {
width: 100%; /* Spans the width of the page */
height: 40px;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgb(94, 185, 176);
}
.navbar {
height: 40px;
margin: 0;
padding: 0;
border-right: 1px solid #54879d;
}
.navbar li {
height: 50px;
width: 155px;
float: right;
text-align: center;
list-style: none;
margin: 0;
background-color: rgb(94, 185, 176);
font: normal 200%/110% 'chocolatebox deco regular',sans-serif;
font-size: 16px;
}
.navbar a {
padding: 14px 0; /* Adds a padding on the top and bottom so the text appears centered vertically */
border-left: 1px solid #74e3d8; /* Creates a border in a slightly lighter shade of blue than the background. */
border-right: 1px solid #4d9a92; /* Creates a border in a slightly darker shade of blue than the background. */
text-decoration: none; /* Removes the default hyperlink styling. */
color: black;
display: block;
}
.navbar li a:hover {
background-color: #ffe643;
}
.navbar li.active {
background-color: #ffe643;
border-bottom: 5px dashed black;
text-decoration: underline;
}
**/* 2nd Nav bar */**
#subnav {
width: 100%; /* Spans the width of the page */
height: 40px;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #ffe643;
}
.subnavbar {
height: 40px;
margin: 0;
padding: 0;
border-right: 1px solid #54879d;
}
.subnavbar li {
height: 50px;
width: 155px;
float: right;
text-align: center;
list-style: none;
margin: 0;
background-color: #ffe643;
font: normal 200%/110% 'chocolatebox deco regular',sans-serif;
font-size: 16px;
}
.subnavbar a {
padding: 14px 0; /* Adds a padding on the top and bottom so the text appears centered vertically */
border-left: 1px solid #fefefb; /* Creates a border in a slightly lighter shade of yellow than the background. */
border-right: 1px solid #fee121; /* Creates a border in a slightly darker shade of yellow than the background. */
text-decoration: none; /* Removes the default hyperlink styling. */
color: black;
display: block;
}
.subnavbar li:hover, a:hover {
background-color: #CFEAE7;
}
.subnavbar li.active {
background-color: #CFEAE7;
**/* Drop down menu */**
.subnavbar li ul {
display: none; /* Hides the drop-down menu */
z-index: 999;
height: 50px;
margin: 0; /* Aligns drop-down box underneath the menu item */
padding: 0; /* Aligns drop-down box underneath the menu item */
background-color: rgb(94, 185, 176);
}
.subnavbar li:hover ul {
display: block; /* Displays the drop-down box when the menu item is hovered over */
}
.subnavbar li ul li a {
border-left: 1px solid #74e3d8;
border-right: 1px solid #74e3d8;
border-top: 1px solid #4d9a92;
border-bottom: 1px solid #4d9a92;
}
.subnavbar li ul li a:hover{
background-color: #ffe643;
}
HTML CODE (This is the code for both nav bars)
<div id="nav">
<ul class="navbar">
<li>Content Writing</li>
<li>Editing</li>
<li>Video Courses</li>
<li class="active">Tutoring</li>
<li><a href=http://tutorwithkatie.org/Blog/blog-2>Blog</a></li>
<li>Home</li>
</ul>
<div id="subnav">
<ul class="subnavbar">
<li></li>
<li>Resources
<ul>
<li>English Resources</li>
<li>Math Resources</li>
<li>Study skills and organization Resources</li>
<li>Parent Resources</li>
</ul>
</li>
<li>Contact Me
<ul>
<li>Request Information</li>
<li>Schedule new client appoitnment</li>
<li>Contact Details</li>
</ul>
</li>
<li>Policies</li>
<li>Current Students
</li>
<li>Services
<ul>
<li>English Tutoring</li>
<li>Homeschool English</li>
<li>Math Tutoring</li>
<li>Online Tutoring</li>
</ul>
</li>
</ul>
<div>
So I have display: none; to hide it and then display: block; to show it on hover, but it no longer displays it on hover. It used to and then the moment I added the first nav bar and called this class .subnavbar, it stopped working....
The reason it isn't working is because you have a lot of issues:
Extra * in your code that are causing CSS issues and are messing up with you CSS. Take all the comment lines out that look like this:
**/* Drop down menu */**
and replace them with a valid comment like this:
/* Drop down menu */
There also is a missing closing } on this CSS rule
.subnavbar li.active {
background-color: #CFEAE7;
and also change this line on the #subnav from overflow: hidden; to overflow: visible; to display the SubNav when you hover over it.
#subnav {
width: 100%; /* Spans the width of the page */
height: 40px;
margin: 0;
padding: 0;
overflow: visible;
background-color: #ffe643;
}
Also a missing closing </div> tag in the HTML for <div id="nav"> and also you have a <div> instead of a closing </div> at the end of the <div id="subnav">.
Here is a working JSFIDDLE for reference where it is working. Hope that clears things up.
i try to edit my code in jsfiddle until it works properly and at last it works properly in jsfiddle and output is same as want i want but when i try this same code in my abc.html page and also css then code does not work whether this work in jsfiddle
HERE SIS JSFIDDLE IMAGE WITH CODE AND OUTPUT
AND HERE IS MY CODE AND HTML
.wrap {
width: 100%;
/* Spans the width of the page */
height: 40px;
margin: 0;
/* Ensures there is no space between sides of the screen and the menu */
z-index: 99;
/* Makes sure that your menu remains on top of other page elements */
position: relative;
background-color: #366b82;
}
.navbar {
height: 50px;
padding: 15px;
margin: 0;
position: absolute;
/* Ensures that the menu doesn’t affect other elements */
border-right: 1px solid #54879d;
margin-left: 55px;
padding-left: 15px;
padding-bottom: 15px;
padding-top: 0px;
margin-left: 25px;
}
.navbar li {
height: auto;
width: 131px;
/* Each menu item is 150px wide */
float: left;
/* This lines up the menu items horizontally */
text-align: center;
/* All text is placed in the center of the box */
list-style: none;
/* Removes the default styling (bullets) for the list */
font: normal bold 12px/1.2em Arial, Verdana, Helvetica;
padding: 0;
margin: 0;
background-color: #366b82;
}
.navbar a {
padding: 18px 0;
/* Adds a padding on the top and bottom so the text appears centered vertically */
border-left: 1px solid #54879d;
/* Creates a border in a slightly lighter shade of blue than the background. Combined with the right border, this creates a nice effect. */
border-right: 1px solid #1f5065;
/* Creates a border in a slightly darker shade of blue than the background. Combined with the left border, this creates a nice effect. */
text-decoration: none;
/* Removes the default hyperlink styling. */
color: white;
/* Text color is white */
display: block;
}
.navbar li:hover,
a:hover {
background-color: #54879d;
}
.navbar li ul {
display: none;
/* Hides the drop-down menu */
height: auto;
margin: 0;
/* Aligns drop-down box underneath the menu item */
padding: 0;
/* Aligns drop-down box underneath the menu item */
}
.navbar li:hover ul {
display: block;
/* Displays the drop-down box when the menu item is hovered over */
}
.navbar li ul li {
background-color: #54879d;
}
.navbar li ul li a {
border-left: 1px solid #1f5065;
border-right: 1px solid #1f5065;
border-top: 1px solid #74a3b7;
border-bottom: 1px solid #1f5065;
}
.navbar li ul li a:hover {
background-color: #366b82;
}
/* i add this css code for link box*/
.navbar li ul li ul li {
display: block;
}
.b:hover .a {
display: block;
margin-left: 130px;
margin-top: -50px;
}
.a {
display: none;
}
<div id="menu">
<div id="wrap">
<ul class="navbar">
<li>HOME
</li>
<li>ABOUT US
<ul id="Ul1">
<li><a id="A1" href="Company_Profile.html">Company Profile</a>
</li>
<li>Our Philsohpy
</li>
<li>CEO Profile
</li>
<li>Board of Directors
</li>
<li>Our People
</li>
<li>Global Partnership
</li>
<li>Career
</li>
</ul>
</li>
<li>TRAINING
<ul id="Ul2">
<li><a id="A2" href="Academics.html">Academics</a>
</li>
<li>Corporate
</li>
<li>Our Personnel
</li>
</ul>
</li>
<li>PUBLISHING
</li>
<li>CONFERENCES
</li>
<li>EXHIBITION
</li>
<li>RESEARCH
<ul id="subnavlist">
<li><a id="subcurrent" href="About_gjbssr.html">About GJBSSR</a>
</li>
<ul class="c">
<li class="a"> Link
</li>
</ul>
<li>Data Collection Services
</li>
<li>Editing & Proof Reading
</li>
</ul>
</li>
<li id="active">CONTACT US
</li>
</ul>
</div>
</div>
and output is
I managed to cure a similar problem by right clicking the result window of jsfiddle and choosing "View Frame Source". Then simply copying and pasting into a new html document. Hope this helps.
I am not sure what went wrong for you. I used the same code to see if it works and it worked for me. In case you are new to HTML and CSS, you need to have a starting and closing tags for html and body. Also a head tag to link your CSS file to it.
<html>
<head>
<style>
<!-- your CSS here -->
</style>
</head>
<body>
<!-- your HTML here -->
</body>
</html>
I have an issue floating an ul next to some text.
Here is the image:
I'm thinking maybe I have to use the relative position attribute to display it the way I want it to? But, I know for a fact that the float property should be used, but it's not working for me. I've tried using another div(logoAndMainMenu-Wrapper) to create a wrapper for the text and ul, but the float property still isn't working....
Here's my HTML:
<div id="topbar">
<div class="fixedWidth1">
<div class="logoAndMainMenu-Wrapper">
<p>The Official Website of<br />
<span id="AndrewVuText">Andrew Vu</span></p>
<ul>
<li>HOME</li>
<li>ABOUT</li>
<li>PROJECTS</li>
<li>COLLABORATE</li>
<li>CONTACT</li>
</ul>
</div> <!-- Logo & Main Menu Wrapper DIV -->
</div> <!-- Fixed Width 1 DIV -->
</div> <!-- Top Bar DIV -->
And here's my CSS:
#AndrewText {
font-size: 2em;
}
.fixedWidth1 {
margin: 0 auto;
width: 1000px;
height: 150px;
background-color: green;
border: 2px solid black;
}
.logoAndMainMenu-Wrapper {
border: 2px solid yellow;
}
.fixedWidth1 ul {
list-style-type: none;
text-align: center;
margin: 0;
background-color: green;
border: 2px solid orange;
}
.fixedWidth1 ul li {
display: inline; /* LI are horizontal */
padding: 5px;
border-right: 2px solid yellow;
}
.fixedWidth1 ul li a {
text-decoration: none; /* No UNDERLINE */
}
/* Normal, unvisited link */
.fixedWidth1 ul li a:link {
color: #FFFFFF;
}
/* Visited link */
.fixedWidth1 ul li a:visited {
color: #FFFFFF;
}
/* Mouse over link */
.fixedWidth1 ul li a:hover {
color: yellow;
}
/* Selected link */
.fixedWidth1 ul li a:active {
color: #FFFFFF;
}
Any help will do. Thanks!!!
Hi now define your p tag float left .logoAndMainMenu-Wrapper define this overflow hidden and as like this
.logoAndMainMenu-Wrapper>p{
float:left;
}
.logoAndMainMenu-Wrapper{overflow:hidden;}
Demo
Here is what I have - http://jsfiddle.net/SQApr/
CSS
/*
** MainNav is the div containing the navigation information
** This is defining overall size and shape
*/
#mainNav {
clear: both;
min-height: 40px;
width: 100%;
font-size: 18px;
position: relative;
}
/*
** Main list padding and style
*/
#mainNav ul {
padding: 0;
margin: 0 auto;
list-style: none;
}
/*
** Expand nav list for new information
*/
#mainNav ul:hover {height: 240px;}
/*
** Main item size and position
*/
#mainNav li {
float: left;
width: 19.805%;
height: 40px;
border-left: 1px solid #E8DEA5; /*******************************************/
border-right: 1px solid #E8DEA5; /* Make the border exist for sizing issues */
border-top: 1px solid #E8DEA5; /*******************************************/
}
/*
** Main item on hover
*/
#mainNav li:hover {
background-color: #ffffff; /* White */
border-left: 1px solid green;
border-right: 1px solid green;
border-top: 1px solid green;
border-bottom: 1px solid white;
}
/*
** Main item link formatting
*/
#mainNav li a {
margin: 0;
display: block;
line-height: 40px;
text-align: center;
text-decoration: none;
color: #000000; /* Black */
}
/*
** Main div position and bg color on list item hover
*/
#mainNav li:hover .mainDiv {
position: absolute;
left: 0;
background-color: #ffffff; /* White */
}
/*
** Any div within mainNav's li must have position relative
*/
#mainNav li div {
position: relative;
padding: 0;
margin: 0;
}
/*
** Main div position
*/
#mainNav li .mainDiv {
width: 1024px; /* Same as #wrapper in styles.css */
height: 200px;
left: -9999px;
border: 1px green solid;
}
#mainNav li .title {
clear: both;
position: relative;
top: 30px;
left: 50px;
font-size: 24px;
font-weight: bold;
color: #0b5a5a; /* Gray blue */
border-bottom: 2px solid #0b5a5a; /* Gray blue */
}
.navLinks li {
float: left;
display: block;
border: none;
}
HTML
<div style="width:1024px;">
<div id="mainNav">
<ul>
<li>Home
<div class="mainDiv">
<span class="title">Welcome to the website!</span>
<div style="border:red 1px solid;
top: 60px;
left: 60px;
width: 400px;
height: 80px;">
Here will be a paragraph filled with more information about what the site does
and how it will benefit the community and companies. Or anything else you
would like to say on every page.
</div>
<div style="border:red 1px solid;
clear: both;
top: -60px;
left: 600px;
width: 200px;
height: 80px;">
<ul class="navLinks">
<li>item 1</li>
<li>item 2</li>
<li>Third link</li>
</ul>
</div>
</div>
</li>
<li>Community
<div class="mainDiv">
<span class="title">Community</span>
Browse People & Companies</br>
Directory</br>
Make Your Voice Heard</br>
Forums
</div>
</li>
<li>Information
<div class="mainDiv">
<span class="title">Information</span>
First link</br>
List within a list
First link</a></br>
Second link</a></br>
Section Title</br>
Third link
</br>
Third link
</div>
</li>
<li>Business Opportunities
<div class="mainDiv">
<span class="title">Business Opportunities</span>
First link</br>
Second link</br>
Third link
</div>
</li>
<li>Support
<div class="mainDiv">
<span class="title">Support</span>
FAQs</br>
Site Map</br>
Third link
</div>
</li>
</ul>
</div>
</div>
When ever you roll over the list items to display the hidden div they contain, the top border of the div overlaps the bottom border of the list item. I need to reverse this to make it look like the list item opens up into the div.
Any ideas?
give the div that opens up a z-index: -1
like here: http://jsfiddle.net/SQApr/3/
You can use the z-index property to put the nav over the mainDiv, giving the mainDiv a lower value than the nav.
z-index at W3Schools
Change li:hover a - add white bottom border, make its position relative to add z-index
See: http://jsfiddle.net/SQApr/1/
By the way: I also had to add negative margin to li:hover .mainDiv
Edit:
Chanckjh version is much simpler than mine.
add List Image and Background Image to <li> items...
CSS Code :-
.sidebarmenu ul{
margin: 0;
padding: 0;
list-style-type: disc;
font:bold 14px Verdana;
width: 180px; /* Main Menu Item widths */
border: 2px solid skyblue;
}
.sidebarmenu ul li{
position: relative;
}
/* Top level menu links style */
.sidebarmenu ul li a{
display: list-item;
overflow: auto; /*force hasLayout in IE7 */
color: red;
text-decoration: none;
padding: 6px;
border-bottom: 1px solid #778;
border-right: 1px solid #778;
}
.sidebarmenu ul li a:link, .sidebarmenu ul li a:visited, .sidebarmenu ul li a:active{
background-color: lightblue;/*background of tabs (default state)#012D58*/
}
.sidebarmenu ul li a:visited{
color: black;
}
.sidebarmenu ul li a:hover{
background-color: lightskyblue;
}
/*Sub level menu items */
.sidebarmenu ul li ul{
position: absolute;
width: 170px; /*Sub Menu Items width */
top: 0;
visibility: hidden;
}
.sidebarmenu a.subfolderstyle{
background: url(images/right.gif) no-repeat 97% 50%;
}
HTML FORM:-
<body>
<div class="sidebarmenu">
<ul id="sidebarmenu1">
<li>Add Location
<ul>
<li>Add Flat</li>
<li>Add Area</li>
</ul>
</li>
<li>Log Out</li>
</ul>
</div>
</body>
first of all... your table structure and your ul-li structure is different:
table cells are all on same level // li levels are different
link names are different
i guess what you want to do is:
set the "images/user_manager.jpg" Image to the list-style-image
as we dont see the images and dont know what they are looking like i
believe you want to set the "images/bg.jpg" Image as the
background-image of the li-tags
in situations like that a screenshot or link would be nice.