I have created a local navigation menu for my web site. It contains 2 li elements as shown on the picture Once you click on the item a black border should be displayed around the href and the name Item should be changed to white with black background.
$(document).ready(function() {
$("li").addClass("liNavA");
$("a").addClass("active");
});
div.figure {
background-color: black;
border-radius: 50%;
width: auto;
}
li.liNav {
list-style-type: none;
display: inline-block;
margin-top: 18px;
margin-left: 4px;
text-align: left;
border: solid 12px black;
border-radius: 24px;
background-color: black
}
li.liNavA {
list-style-type: none;
display: inline-block;
margin-top: 18px;
margin-left: 4px;
text-align: left;
border: solid 12px white;
border-radius: 24px;
color: white;
background-color: white;
}
a.active {
color: white;
text-decoration: none;
}
a.pasive {
color: black;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="localnavDiv">
<ul class="localNav">
<li class="liNav" id="exploreTitle"><a class="active" id="titleLi" id="exploreTitle">Explore</a></li>
<li class="liNavA"><a class="pasive" href="#">Who already joined</a></li>
<li class="liNav" ><a class="active" href="#">Why develop for us </a></li>
</ul>
</div>
<style type="text/css">
div.figure {
background-color: black;
border-radius: 50%;
width: auto;
}
li.liNav {
list-style-type: none;
display: inline-block;
margin-top: 18px;
margin-left: 4px;
text-align: left;
border: solid 2px black;
padding: 5px;
border-radius: 24px;
background-color: #FFFFFF
}
li.liNavA {
list-style-type: none;
display: inline-block;
margin-top: 18px;
margin-left: 4px;
text-align: left;
border: solid 2px white;
padding: 5px;
border-radius: 24px;
color: white;
background-color: #000000;
}
li.liNavA a {
color: white;
}
a.active {
text-decoration: none;
}
a.pasive {
text-decoration: none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="localnavDiv">
<ul class="localNav">
<li class="liNav" id="exploreTitle"><a class="active" href="#">Explore</a></li>
<li class="liNav" id="liRight"><a class="pasive" href="#">Who already joined</a></li>
<li class="liNav" id="liLeft"><a class="active" href="#">Why develop for Hue</a></li>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function() {
/**
* add event listner for every list-item
*/
$("#exploreTitle").click(function(){
$("#exploreTitle").attr('class', 'liNavA');
$("#liRight").attr('class', 'liNav');
$("#liLeft").attr('class', 'liNav');
})
$("#liRight").click(function(){
$("#liRight").attr('class', 'liNavA');
$("#exploreTitle").attr('class', 'liNav');
$("#liLeft").attr('class', 'liNav');
})
$("#liLeft").click(function(){
$("#liLeft").attr('class', 'liNavA');
$("#liRight").attr('class', 'liNav');
$("#exploreTitle").attr('class', 'liNav');
})
});
</script>
Related
I found good split dropmenu button script.
Created multiple buttons, and problem is if I click one button then all dropmenus of other buttons open...
So what I want to accomplish is only to open dropmenu that i've clicked not all menus (10post per page so i have 10buttons) that are on page.
Guess I need some id recognition code in my .js.
my script:
$(function() {
var splitBtn = $(".x-split-button");
$("button.x-button-drop").on("click", function() {
if (!splitBtn.hasClass("open"))
splitBtn.addClass("open");
});
$(".x-split-button").click(function(event) {
event.stopPropagation();
});
$("html").on("click", function() {
if (splitBtn.hasClass("open"))
splitBtn.removeClass("open");
});
});
.x-split-button {
position: relative;
display: inline-block;
text-align: left;
margin-top: 20px;
}
.x-button {
position: relative;
margin: 0;
height: 30px;
float: left;
outline: none;
font-weight: 600;
line-height: 27px;
background: #F2F2F2;
border: 1px solid #E0E0E0;
box-shadow: 1px 1px 2px #E0E0E0;
}
.x-button:hover {
cursor: pointer;
background: #E0E0E0;
}
.x-button:active {
background: #D3D3D3;
}
.x-button.x-button-drop {
border-left: 0;
height: 30px;
}
.open > .x-button-drop-menu {
display: block;
}
.x-button-drop-menu {
position: absolute;
top: 27px;
right: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 14px;
list-style: none;
background-color: #F2F2F2;
color: #000000;
background-clip: padding-box;
border: 1px solid #E0E0E0;
box-shadow: 1px 1px 2px #E0E0E0;
}
.x-button-drop-menu li a {
display: block;
padding: 3px 20px;
clear: both;
font-family: arial;
color: #000000;
text-decoration: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<center><font color="green">1st forum post....text goes here....</font><br/>
<span class="x-split-button">
<button class="x-button x-button-main">Admin Options</button>
<button class="x-button x-button-drop">▼</button>
<ul class="x-button-drop-menu">
<li>
Edit
</li>
<li>
Delete
</li>
<li>
Move
</li>
</ul>
</span>
<br/><br/><br/><br/><br/><font color="green">2nd forum post....text goes here....</font><br/>
<span class="x-split-button">
<button class="x-button x-button-main">Admin Options</button>
<button class="x-button x-button-drop">▼</button>
<ul class="x-button-drop-menu">
<li>
Edit
</li>
<li>
Delete
</li>
<li>
Move
</li>
</ul>
</span>
</center>
jQuery $(this) is concerned about the element concerned in this function (Onclick). We use closest() to reach The parent container (.x-split-button) which is the targeted element in this case.
We can also use $(this).parent(".x-split-button").addClass("open");
In other situations, you could use $(this).parents(); when the container is not a direct parent.
$(function() {
var splitBtn = $(".x-split-button");
$("button.x-button-drop").on("click", function() {
if (!($(this).closest(".x-split-button").hasClass("open"))){
splitBtn.removeClass("open");
$(this).closest(".x-split-button").addClass("open");
}else{
$(this).closest(".x-split-button").removeClass("open");
}});
$(".x-split-button").click(function(event) {
event.stopPropagation();
});
$("body").on("click", function() {
if (splitBtn.hasClass("open"))
splitBtn.removeClass("open");
});
});
.x-split-button {
position: relative;
display: inline-block;
text-align: left;
margin-top: 20px;
}
.x-button {
position: relative;
margin: 0;
height: 30px;
float: left;
outline: none;
font-weight: 600;
line-height: 27px;
background: #F2F2F2;
border: 1px solid #E0E0E0;
box-shadow: 1px 1px 2px #E0E0E0;
}
.x-button:hover {
cursor: pointer;
background: #E0E0E0;
}
.x-button:active {
background: #D3D3D3;
}
.x-button.x-button-drop {
border-left: 0;
height: 30px;
}
.open > .x-button-drop-menu {
display: block;
}
.x-button-drop-menu {
position: absolute;
top: 27px;
right: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 14px;
list-style: none;
background-color: #F2F2F2;
color: #000000;
background-clip: padding-box;
border: 1px solid #E0E0E0;
box-shadow: 1px 1px 2px #E0E0E0;
}
.x-button-drop-menu li a {
display: block;
padding: 3px 20px;
clear: both;
font-family: arial;
color: #000000;
text-decoration: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<center><font color="green">1st forum post....text goes here....</font><br/>
<span class="x-split-button">
<button class="x-button x-button-main">Admin Options</button>
<button class="x-button x-button-drop">▼</button>
<ul class="x-button-drop-menu">
<li>
Edit
</li>
<li>
Delete
</li>
<li>
Move
</li>
</ul>
</span>
<br/><br/><br/><br/><br/><font color="green">2nd forum post....text goes here....</font><br/>
<span class="x-split-button">
<button class="x-button x-button-main">Admin Options</button>
<button class="x-button x-button-drop">▼</button>
<ul class="x-button-drop-menu">
<li>
Edit
</li>
<li>
Delete
</li>
<li>
Move
</li>
</ul>
</span>
</center>
I am building a website for a college class and I've run into a problem. I can't seem to find the answer when I google it, so I made an account to post it here. I hope that someone is able to identify what is going on.
As you can see, the embedded twitter post is showing up on top of the hamburger menu and I'm not sure how to get it underneath.
Here is the HTML (It's still a work in progress and I'm pretty new so please forgive me for any ugly code):
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="height=device-height, initial-scale=1.0">
<link rel="stylesheet" href="css/menu.css">
<link rel="stylesheet" href="css/style.css">
<link rel="shortcut icon" type="image/png" href="images/run.png">
</head>
<body>
<header>
<div id="weatherBar" class="weatherBar">
<button class="hamburger">☰</button>
<button class="cross">˟</button>
<nav class="menu">
<ul>
<li>
About the Events
<ul class="submenu">
<li>Starting Times</li>
<li>Course Details</li>
<li>What to Bring</li>
</ul>
</li>
<li>Upcoming Events</li>
<li>Registration</li>
<li>Packet Pick Up</li>
<li>About Us</li>
<li>FAQs</li>
<li>Contact</li>
</ul>
</nav>
<div class="socialLinks">
<img src="images/fb-ico.png" alt="" class="iconHeight">
<img src="images/twit-ico.png" alt="" class="iconHeight">
<img src="images/inst-ico.png" alt="" class="iconHeight">
</div>
</div>
</header>
<main class="wrapper">
<div id="details" class="details lightSub contentFill contentPad">
<h2 class="subHeader">What People are Saying</h2>
<div class="sub_head_line_white"></div>
<div class="socialWrapper centering">
<iframe src="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fcas222cascade%2Fposts%2F366912850439109&width=350&show_text=true&height=214&appId" width="350" height="214" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>
</div>
<div class="socialWrapper centering">
<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Fantastic weather for training! Can't wait to get in the water for open water swims!</p>— CAS 222 (#pcccas222) May 10, 2018</blockquote>
</div>
</div>
</main>
<footer></footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="scripts/ham.js"></script>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</body>
</html>
Here is the javascript:
$(document).ready(function () {
$(".cross").hide();
$(".menu").hide();
$(".hamburger").show();
$(".hamburger").on("click", function () {
$(".menu").slideToggle("slow");
$(".hamburger").hide();
$(".cross").show();
});
$(".cross").on("click", function () {
$(".menu").slideToggle("slow");
$(".cross").hide();
$(".hamburger").show();
});
$(".menu a").on("click", function () {
$(".menu").slideToggle("slow");
$(".cross").hide();
$(".hamburger").show();
});
});
Here is the CSS:
Menu.css
.hamburger {
background: none;
position: relative;
top: 0;
right: 0;
line-height: 35px;
color: red;
border: 0;
font-size: 1.4em;
font-weight: 700;
cursor: pointer;
outline: none;
z-index: 10;
}
.cross {
background: none;
position: relative;
top: 0;
right: 0;
color: red;
border: 0;
font-size: 3em;
line-height: 55px;
font-weight: 700;
cursor: pointer;
outline: none;
z-index: 10;
}
.socialLinks {
background: none;
position: fixed;
top: 8px;
right: 10px;
color: red;
border: 0;
cursor: pointer;
outline: none;
z-index: 10;
}
.iconHeight {
height: 20px;
}
.menu {
/* z-index: 10;*/
font-weight: 700;
width: 100%;
height: 100vh;
background: rgb(0, 0, 0, .85);
position: absolute;
top: 25px;
padding-top: 20px;
right: 0;
text-align: left;
font-size: 2em;
text-decoration: none;
color: white;
font-family: 'Roboto Condensed', sans-serif;
z-index: 10;
}
.menu ul {
list-style-type: none;
list-style-image: none;
margin: 0;
padding: 0;
text-decoration: none;
color: white;
}
.menu li {
display: block;
padding: 15px 0;
padding-left: 25px;
padding-right: 25px;
}
.menu li:hover {
display: block;
padding: 15px 0;
padding-left: 25px;
padding-right: 25px;
color: red;
}
.menu ul a {
text-decoration: none;
color: white;
margin: 0;
}
.menu ul a:hover {
text-decoration: none;
color: red;
}
.menu ul a:active {
text-decoration: none;
color: white;
}
.menu ul a:visted {
text-decoration: none;
color: gray;
}
.submenu li {
padding-left: 25px;
}
style.css
body {
.grayGradient;
}
main {}
.hero {
background-image: url(../images/run3.jpg);
background-size: auto;
background-position: center;
height: 500px;
width: 100%;
}
.heroBot {
width: 100%;
height: 20px;
background-color: #000;
}
.weatherBar {
position: fixed;
height: 40px;
width: 100%;
background: black;
border-bottom: 3px red solid;
margin-left: auto;
margin-right: auto;
}
footer {
height: 30px;
width: 100%;
background: black;
border-top: 3px red solid;
}
h1 {
.fontOswald;
font-size: 60px;
color: white;
font-weight: bold;
text-align: center;
}
.headerSize {
font-size: 50px;
.fontNarrow;
font-weight: normal;
letter-spacing: 1px;
}
.titleDiv {
padding-left: 15px;
width: 95%;
padding-top: 40px;
margin-left: auto;
margin-right: auto;
padding-right: 15px;
border-bottom: 3px red solid;
}
.titleText {
padding-top: 20px;
padding-bottom: 20px;
}
.disc {
margin-top: 40px;
margin-bottom: 20px;
background-color: #fff;
padding: 20px;
.fontBaseText;
font-size: 1.5em;
color: #000;
text-align: center;
font-weight: lighter;
line-height: 30px;
}
.facebookFeed {
margin-left: auto;
margin-right: auto;
display: block;
}
.contentPad {
padding: 20px 20px 45px 20px;
}
.contentFill p {
font-size: 1.2em;
.fontBaseText;
line-height: 25px;
padding-top: 5px;
padding-bottom: 5px;
}
.subHeader {
.fontNarrow;
font-size: 1.8em;
}
.subHeaderAlt {
.fontNarrow;
font-size: 1.8em;
color: #fff;
}
.sub_head_line {
height: 5px;
width: 95%;
.grayGradientBtR;
}
.sub_head_line_white {
height: 5px;
width: 95%;
.grayGradientWtR;
}
.darkSub {
background-color: #000;
color: #fff;
}
.lightSub {
background-color: #fff;
color: #000;
}
.tableDay {
text-align: center;
font-size: 1.2em;
.fontNarrow;
}
.timesTable {
margin: 10px;
margin-top: 20px;
align-content: center;
.fontBaseText;
}
.timesTable tr:first-child {
border: none;
}
.timesTable tr {
border-left: 2px #mainRed solid;
border-right: 2px #mainRed solid;
}
.timesTable table,
tr,
td,
th {
border-collapse: collapse;
padding: 3px;
}
.timesTable th {
font-weight: bold;
padding: 10px;
}
.timesTable td {
padding: 10px;
}
.timesTable tr:nth-child(even) {
background-color: #darkGray;
}
.raceName {
width: 180px;
}
.raceTime {
width: 100px;
}
.startingTimeTableWrapper {
width: 100%;
}
.centering {
.marginCenter;
}
.socialWrapper {
width: 350px;
margin-top: 10px;
z-index: -1;
}
.subHeader:before {
height: 25px;
display: block;
content: '';
}
.subHeaderAlt:before {
height: 25px;
display: block;
content: '';
}
I need to make a drop down menu from "menu4" on the code below. The code is running well but I need to introduce a drop down menu. I have tried different ways to have a list inside a list but seems not to work. I really need someones help. Anyone? Thanks.
document.getElementById("nav01").innerHTML =
"<ul id='menu'>" +
" <li><a href= '#'>Home</a></li> " +
" <li><a href= '#'>menu1</a></li> " +
" <li><a href= '#'>menu2</a></li> " +
" <li><a href = '#'>menu3</a></li> " +
" <li><a href = '#'>menu4</a></li> " +
" <li><a href = 'index.php'> Log Out</a></li> " +
"</ul>";
body {
font-family: Bookman Old Style;
font-size: 13px;
background-color:#EBF4FA;
color: #696969;
padding-right: 150px;
padding-left: 150px;
}
#top{
background-color: ;
height: 120px;
box-shadow: 10px #888888;
}
#main {
padding: 5px;
padding-left: 15px;
padding-right: 15px;
background-color: #EBF4F4;
border-radius: 0 0 5px 5px;
border-style: solid;
border-right-width: 1px;
}
h3 {
font-family: Bookman Old Style;
border-bottom: 3px;
color: black;
font-size: 16px;
}
table {
width:100%;
}
table, th , td {
border: 1px solid white;
border-collapse: collapse;
padding: 0px;
}
th {
text-align: left;
}
table tr:nth-child(odd) {
background-color: #ffffff;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
ul#menu {
padding: 0;
margin-bottom: 11px;
}
ul#menu li {
display: inline;
margin-right: 3px;
margin: 100px auto;
line-height:30px;
max-width:860px;
}
ul#menu li a {
background-color: #ffffff;
padding: 10px 20px;
text-decoration: none;
color: #696969;
border-radius: 4px 4px 0 0;
}
ul#menu li a:hover {
color: white;
background-color: black;
}
#footer {
position: right;
color: #ffffff;
}
h1 {
border-bottom: 3px solid orange;
font-size: 30px;
}
<!DOCTYPE html>
<html>
<head>
<title>About</title>
<link href="site.css" rel="stylesheet">
</head>
<nav id="nav01"></nav>
<body>
<div id="main">
<h1>About Us</h1>
<p>Dibon Company Limited is a project delivery and technical consultancy firm that provides efficient and cost effective methodologies and expertise in managing complex as well as simple projects</p>
<div class="box contactdetails">
<h2>Our Contact Details </h2>
<ul>
<li>Dibon Limited Company</li>
<li class="last">Website: dibon</li>
<li>Email: info#dibon</li>
<li class="last">Facebook: Dibon</li>
</ul>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
Are you sure you need javascript for this?
If I understand it correctly, you can do this without javascript. Fully functional dropdown menus can take advantage of hover states for the links. I went ahead and cleaned up some CSS for ya. Check it out. Here's the key CSS:
.navigation-menu li:hover ul {
display: inline-block;
position: absolute;
background-color: #fff;
border: 3px ridge #ccc;
box-shadow:2px 2px 5px 2px #ccc;
padding:5px;
}
http://codepen.io/anon/pen/MebwjB
You don't need any js or something else, do it with css3 (transition) by hover:
.mainMenu {
display: flex;
flex-direction: column;
overflow: hidden;
width: 200px;
height: 30px;
background-color: darkgrey;
color: black;
font-family: Arial;
line-height: 30px;
-webkit-transition: max-height 0.5s ease-in-out;
-moz-transition: max-height 0.5s ease-in-out;
-o-transition: max-height 0.5s ease-in-out;
transition: max-height 0.5s ease-in-out;
}
.mainMenu:hover {
color: white;
background-color: #2f6992;
cursor: pointer;
height: 150px;
}
ul {
padding-left: 15px;
}
li {
list-style: none;
}
li:hover {
color: yellow;
}
.title {
color: white;
background-color: darkgrey;
width: 100%;
height: 30px;
padding-left: 5px;
}
<div class="mainMenu">
<span class="title">HOVER MENU-POINT...</span>
<ul>
<li>Menu 1</li>
<li>Menu 1</li>
<li>Menu 1</li>
</ul>
</div>
Cheers
I have a horizontal HTML tab , where i wish to make the bottom border of the selected tab hidden.
Here is the current code i have - https://jsfiddle.net/vgx2k7p5/
The question has been asked here and here
But both the solutions are not working , since i'm using a div structure and no much javascript.
jQuery('.tab-links a').on('click', function(e) {
var currentAttrValue = jQuery(this).attr('href');
jQuery(currentAttrValue).show().siblings().hide(); //changed here
jQuery(this).parent('li').addClass('active').siblings().removeClass('active');
e.preventDefault();
});
.tabs {
width: 90%;
margin: auto;
}
/*----- Tab Links -----*/
/* Clearfix */
.tab-links:after {
display: block;
clear: both;
content: '';
}
.tab-links {
margin: 0px;
}
.tab-links li {
margin: 0px 3px;
float: left;
list-style: none;
}
.tab-links a {
padding: 9px 15px;
display: inline-block;
border-radius: 3px 3px 0px 0px;
text-decoration: none;
font-size: 16px;
font-weight: 600;
color: #999;
transition: all linear 0.2s;
border: 1px solid #fff;
}
.tab-links a:hover {
text-decoration: none;
/*background: #f1f1f1;*/
/*border-bottom: 4px solid #999; */
}
li.active a,
li.active a:hover {
/* border-bottom: 4px solid #444; */
/*background: #ccc;*/
border: 1px solid #ccc;
border-bottom: 1px solid #fff;
color: #444;
}
/*----- Content of Tabs -----*/
.tab-content {
padding: 15px;
border-radius: 3px;
border: 1px solid #ccc;
background: #fff;
min-height: 300px;
z-index: -99;
}
.tab {
display: none;
min-height: 300px;
}
.tab.active {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="tabs margintop20">
<ul class="tab-links">
<li class="active">PROFILE
</li>
<li>REVIEWS
</li>
<li>REWARDS
</li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab active clearfix">
</div>
<div id="tab2" class="tab">
</div>
<div id="tab3" class="tab">
<h3>Videos and Screenshots</h3>
</div>
</div>
</div>
</div>
What am i doing wrong here ? Both setting the Z-index and increasing the border-bottom width did not work.
I have updated your css with that :
/* ADDED */
.tab-links .active{
margin-top : 1px;
}
.active > a {
margin-bottom: -1px;
}
And now it seems to be working !
jQuery('.tab-links a').on('click', function(e) {
var currentAttrValue = jQuery(this).attr('href');
jQuery(currentAttrValue).show().siblings().hide(); //changed here
jQuery(this).parent('li').addClass('active').siblings().removeClass('active');
e.preventDefault();
});
.tabs {
width: 90%;
margin: auto;
}
/*----- Tab Links -----*/
/* Clearfix */
.tab-links:after {
display: block;
clear: both;
content: '';
}
.tab-links {
margin: 0px;
}
.tab-links li {
margin: 0px 3px;
float: left;
list-style: none;
}
.tab-links a {
padding: 9px 15px;
display: inline-block;
border-radius: 3px 3px 0px 0px;
text-decoration: none;
font-size: 16px;
font-weight: 600;
color: #999;
transition: all linear 0.2s;
border: 1px solid #fff;
}
.tab-links a:hover {
text-decoration: none;
/*background: #f1f1f1;*/
/*border-bottom: 4px solid #999; */
}
li.active a,
li.active a:hover {
/* border-bottom: 4px solid #444; */
/*background: #ccc;*/
border: 1px solid #ccc;
border-bottom: 1px solid #fff;
color: #444;
}
/*----- Content of Tabs -----*/
.tab-content {
padding: 15px;
border-radius: 3px;
border: 1px solid #ccc;
background: #fff;
min-height: 300px;
z-index: -99;
}
.tab {
display: none;
min-height: 300px;
}
.tab.active {
display: block;
}
/* ADDED */
.tab-links .active{
margin-top : 1px;
}
.active > a {
margin-bottom: -1px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="tabs margintop20">
<ul class="tab-links">
<li class="active">PROFILE
</li>
<li>REVIEWS
</li>
<li>REWARDS
</li>
</ul>
<div class="tab-content">
<div id="tab1" class="tab active clearfix">
</div>
<div id="tab2" class="tab">
</div>
<div id="tab3" class="tab">
<h3>Videos and Screenshots</h3>
</div>
</div>
</div>
</div>
I'm trying to create custom drop-down select like the one used on twitter when user logs out and till now I did not succeed :
This is what I achieved but is not working on IE9 :|
http://fiddle.jshell.net/Hz2JH/
<ul id="main">
<li class="username" tabindex="1" >
<a>USER</a>
<ul class="curent_buser">
<li class="help">Help</li>
<li class="logoff">Log Off</li>
</ul>
</li>
</ul>
ul#main {
color: 232323;
width: 120px;
border:2px solid #ccc;
list-style: none;
font-size: 12px;
letter-spacing: -1px;
font-weight: bold;
text-decoration: none;
height:30px;
background:#f1f1f1;
}
ul#main:hover {
opacity: 0.7;
text-decoration: none;
}
#main > li{
background: url('http://cdn1.iconfinder.com/data/icons/crystalproject/24x24/actions/1downarrow1.png') 100% 0 no-repeat;
outline:0;
padding:10px;
}
ul#main li ul {
display: none;
width: 116px;
background: transparent;
border-top: 1px solid #eaeaea;
padding: 2px;
list-style: none;
margin: 7px 0 0 -3px;
}
ul.curent_buser li a {
color: gray;;
cursor: pointer;
}
ul.curent_buser{
background:lime !important;
}
ul#main li ul li a {
display: block;
padding: 5px 0;
position: relative;
z-index: 5;
}
#main li:focus ul, #main li.username:active ul {
display: block;
}
.help{
background: url("http://cdn1.iconfinder.com/data/icons/musthave/16/Help.png") no-repeat 100% center ;
height: 25px;
margin-bottom: 2px;
border-bottom: 1px solid white;
}
.help:hover{
background: #f4f4f4;
}
.logoff{
background: url("http://cdn1.iconfinder.com/data/icons/cc_mono_icon_set/blacks/16x16/on-off.png") no-repeat 100% center ;
height: 25px;
}
.logoff:hover{
background: #f4f4f4 ;
height: 25px;
}
.help a,.logoff a{
color:gray;
font-family: Museo700Regular,sans-serif;
letter-spacing: 0;
font-size: small;
}
So how can I build a custom select like the one used on twitter?
This works for me, doesnt require a click to get the drop down. Just add li elements to put the custom images on each menu item. Straight CSS and works on all browsers I have tested, if you find a browser that doesnt work let me know please.
#addMenu, #addMenu ul {
list-style: none;
}
#addMenu {
float: left;
}
#addMenu > li {
float: left;
}
#addMenu li a {
display: block;
padding: 0 8px;
text-decoration: none;
}
#addMenu ul {
position: absolute;
display: none;
z-index: 999;
}
#addMenu ul li a {
width: 70px;
color: #000;
font-weight: bold;
}
#addMenu li:hover ul.noJS {
display: block;
background: #ccc;
color: #000;
}
#addMenu ul li:hover a {
background: #ddd;
}
HTML
<ul id='addMenu'>
<li>
<a href='#'>MENU</a>
<ul class='noJS'>
<li><a href='URL'>Option1</a></li>
<li><a href='URL'>Option2</a></li>
<li><a href='URL'>Option3</a></li>
<li><a href='URL'>Option4</a></li>
</ul>
</li>
</ul>