Sharepoint navigation stops working with this script embeded into the page - javascript

I am making tabs that change when clicked using Jquery and before and after CSS. When embedded into the SharePoint page the links on the navigation stop working. Everything else works on the page except for the navigation links to the other pages.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function() {
$("li").click(function(e) {
e.preventDefault();
$("li").removeClass("selected");
$(this).addClass("selected");
});
});
</script>
<style>
.tabrow {
text-align: center;
list-style: none;
margin: 50px 0 36px;
padding: 0;
line-height: 24px;
height: 26px;
overflow: hidden;
font-size: 16px;
font-family: verdana;
position: relative;
}
.tabrow li {
border: 1px solid #AAA;
background: #D1D1D1;
background: -o-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: -ms-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: -moz-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: -webkit-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
display: inline-block;
position: relative;
z-index: 0;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 #FFF;
text-shadow: 0 1px #FFF;
margin: 0 -5px;
padding: 0 20px;
}
.tabrow a {
color: #555;
text-decoration: none;
}
.tabrow li.selected {
background: #FFF;
color: #333;
z-index: 2;
border-bottom-color: #FFF;
}
.tabrow:before {
position: absolute;
content: " ";
width: 100%;
bottom: 0;
left: 0;
border-bottom: 1px solid #AAA;
z-index: 1;
}
.tabrow li:before,
.tabrow li:after {
border: 1px solid #AAA;
position: absolute;
bottom: -1px;
width: 5px;
height: 5px;
content: " ";
}
.tabrow li:before {
left: -6px;
border-bottom-right-radius: 6px;
border-width: 0 1px 1px 0;
box-shadow: 2px 2px 0 #D1D1D1;
}
.tabrow li:after {
right: -6px;
border-bottom-left-radius: 6px;
border-width: 0 0 1px 1px;
box-shadow: -2px 2px 0 #D1D1D1;
}
.tabrow li.selected:before {
box-shadow: 2px 2px 0 #FFF;
}
.tabrow li.selected:after {
box-shadow: -2px 2px 0 #FFF;
}
</style>

You are effectively changing the onclick behavior of every <li> element on your sharepoint page with your javascript.
Try to be more specific with your jQuery selector. For example like this:
$(".tabrow li").click(function(e) {
e.preventDefault();
$(this).clostest(".tabrow").find("li").removeClass("selected");
$(this).addClass("selected");
});
Also you might experience problems on production environments, please enclose your jQuery like this:
$(document).ready(function() {
$(".tabrow li").click(function(e) {
e.preventDefault();
$(this).clostest(".tabrow").find("li").removeClass("selected");
$(this).addClass("selected");
});
});
This will execute the code, when page is finished loading (not only when code is reached).

Related

footer button in Android Browser

I am new to CSS and developing a simple template which will be showed inside an Android Browser. Basically my template only has two elements, an error message, and a button (should be placed at footer).
I have read a few posts at stackoverflow. People suggest to use
position:fixed;
bottom: 0;
to place an element at footer. However, when I added this my button css, it seems my button was just placed right below the error message instead of at the footer. Anyone has any ideas why?
.fulfill-application-button{
display: inline-block;
width: 100%;
zoom: 1;
margin: 0;
text-align: center;
cursor: pointer;
border: 1px solid #bbb;
overflow: visible;
font: bold 25px arial, helvetica, sans-serif;
text-decoration: none;
white-space: nowrap;
color: #555;
background-color: #ddd;
transition: background-color .2s ease-out;
background-clip: padding-box;
border-radius: 3px;
box-shadow: 0 1px 0 rgba(0, 0, 0, .3),
0 2px 2px -1px rgba(0, 0, 0, .5),
0 1px 0 rgba(255, 255, 255, .3) inset;
text-shadow: 0 1px 0 rgba(255,255,255, .9);
}
.fulfill-application-button:hover{
background-color: #eee;
color: #555;
}
.fulfill-application-button:active{
background: #e9e9e9;
position: relative;
top: 1px;
text-shadow: none;
box-shadow: 0 1px 1px rgba(0, 0, 0, .3) inset;
}
.fulfill-application-button.color{
color: #fff;
text-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.fulfill-application-button.ok{
position: relative;
bottom: 0;
padding: 10px 90px;
background-color: #c43c35;
border-color: #c43c35;
}
.fulfill-application-button.ok:hover{
background-color: #ee5f5b;
}
.fulfill-application-button.ok:active{
background: #c43c35;
}
html,body
{
padding: 15px;
height: 100%;
background-color: black;
}
div.error-message{
color: white;
line-height: 120%;
padding-top: 20%;
font-size:30px;
}
</style>
<body>
<div class ="error-message">
${error}
</div>
<button id="ok" type="button" class="color ok fulfill-application-button">
OK
</button>
</body>
Change position: relative; to position: fixed; from class .fulfill-application-button.ok
Code :
.fulfill-application-button.ok{
position: fixed;
bottom: 0;
padding: 10px 90px;
background-color: #c43c35;
border-color: #c43c35;
}
Note : You can give right and left for the same, if you want.

How to change tooltip background color?

I have created a tooltip in my html file like this:
<span title="" class="duedate-warning-msg"></span>
And I set the CSS property like this:
.duedate-warning-msg{
background: url("/static/img/error.png") no-repeat scroll 14px 12px white;
border-color: #f5c7c7;
padding: .5em 0.25em 0.5em 2.5em;
title:"my tooltip";
color: #D11006;
}
span:hover{
position:relative;
}
span[title]:hover:after {
content: "This statement is past due.";
padding: 4px 8px;
color: white;
font-size:16px;
font-family: "open_sansregular";
background: #0679ca;
position: absolute;
left: 0;
top: 100%;
white-space: nowrap;
z-index: 20px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0px 0px 4px #222;
-webkit-box-shadow: 0px 0px 4px #222;
box-shadow: 0px 0px 4px #222;
background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc));
background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
}
The above style created tooltip perfectly. Only problem which I am facing is that I want background color of tooltip is blue. But it always shows gray. Why it is happening so?
Remove the background-image and add background, like so:
span[title]:hover:after {
content: "This statement is past due.";
padding: 4px 8px;
color: white;
font-size:16px;
font-family: "open_sansregular";
background: #0679ca;
position: absolute;
left: 0;
top: 100%;
white-space: nowrap;
z-index: 20px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0px 0px 4px #222;
-webkit-box-shadow: 0px 0px 4px #222;
box-shadow: 0px 0px 4px #222;
background: #00F;
}
Easy, in background-image property replace #cccccc with a color of your choice, assuming that you want to keep the fade-to-almost-white (#eeeeee) gradient.
Remove the background image from span[title]:hover:after
Here is the working Demo

IE8: element:first-child deosn't work (selects parent of what I actually want)

Works in chrome, not ie8: http://jsfiddle.net/a7rXZ/2/
so, when you click on accepted, decline, or open, it changes the text adjacent to the little click menu (while maintaining styling of the text on the left (this is ideal)). but in IE, it seems to be replacing the parent element (cause the styling of the text doesn't remain the same)
any ideas for how to get this to behave in IE8?
this is the code in question:
$j('.change_option').click(function() {
$j('#change_status_menu').fadeToggle("fast");
$j(".status .status_header span:first-child").attr("class", $j(this).html());
$j(".status .status_header span:first-child").html($j(this).html());
$j('#proposal_status').val($j(this).attr("name"));
unsaved_changes = true;
});
I suspect IE just has a problem with mark-up in class attributes. I wouldn't blame IE though since it's totally invalid. The solution is really a case of making the mark-up cleaner and copying only the relevant sections of text/mark-up from the options to the status header.
I've cleaned up the mark-up a little and re-worked the jQuery to select only the text() and class necessary for manipulating the status-header element. Basically, I've turned the options into an unordered list, rather than using a combination of <div> and <span>. So it might not be exactly what you are after, since I am not sure if you can change the mark-up and I have also removed the the .badge class.
The problems were mainly that the JavaScript was adding HTML content into the class attribute of the .status-header span element, but also a lot of the text in the example was outside any element, so the JavaScript was actually selecting too much content each time. The other problem I could see was that you had already duplicated the mark-up for the secondary status heading, so rather than replacing this HTML each time, it was easier to just extract the one class ('Open', 'Accepted' or 'Declined') and the text of the option.
There is more that can be done to simplify the code, for example the .class and text() being copied to the header are now exactly the same so should be simplified.
Here is a demo which is working for me in Chrome and IE8
For completeness, here is all the code:
HTML
<div class="proposal_status">
<div id="change_status_menu" style="">
<div class="change_status_menu">
<ul class="container">
<li class="Open" name="1">Open</li>
<li class="Accepted" name="2">Accepted</li>
<li class="Declined" name="3">Declined</li>
</ul>
</div>
<div class="arrow_border_2"></div>
<div class="arrow_border"></div>
<div class="arrow"></div>
</div>
<input id="proposal_status" name="proposal[status]" type="hidden" value="2">
<div class="status">
<div class="status_header">
<span class="Accepted">Accepted</span>
<div class="action_button change_status">Change Status</div>
</div>
<div class="info">
<div class="prop-status-details">
Accepted by
<strong>aoei eui</strong> from
<strong>127.0.0.1</strong>
</div>
</div>
</div>
</div>
JavaScript
$j = jQuery.noConflict();
$j(function() {
$j(".change_status").click(function() {
$j('#change_status_menu').fadeToggle("fast");
});
$j('li').click(function() {
$j('#change_status_menu').fadeToggle("fast");
$j(".status .status_header span").attr("class", $j(this).attr('class'));
$j(".status .status_header span").html($j(this).text());
$j('#proposal_status').val($j(this).attr("name"));
unsaved_changes = true;
});
});
CSS
.no_padding{
padding: 0px !important;
}
.properties-shell {
background: #f3f3f3;
width: 930px;
position: relative;
border-right: solid 10px #f3f3f3;
border-left: solid 10px #f3f3f3;
}
.properties-shell-top {
margin-top: 15px;
background: url(../images/bucket_wide_bg.gif) no-repeat;
width: 950px;
height: 10px;
overflow: hidden;
}
.properties-shell-bottom {
background: url(../images/bucket_wide_bg.gif) 0 -10px no-repeat;
width: 950px;
height: 10px;
overflow: hidden;
}
.properties-main {
background: #FFF;
display: table;
border-left: solid 1px #e5e5e5;
}
.properties_header{
border-right: solid 1px #e5e5e5;
display: block;
height: 38px;
border-top: rgb(229,229,229);
background: #e5e5e5;
background: -webkit-gradient(linear, left bottom, left top,
color-stop(0%,#e5e5e5),
color-stop(96%,#f2f2f2),
color-stop(97%,#ffffff),
color-stop(98%,#e5e5e5)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Opera11.10+ */
background: -ms-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
background: linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* W3C */
}
.properties_first_col{
padding: 20px;
width: 415px;
float: left;
display: inline-block;
}
.properties_second_col{
padding: 20px;
padding-right: 15px;
width: 210px;
float: left;
display: inline-block;
}
.properties_options{
background: #F7F7F7;
float: right;
padding: 20px;
width: 187px;
border-left: solid 1px #e1e1e1;
border-right: solid 1px #e1e1e1;
border-bottom: solid 1px #e1e1e1;
min-height: 268px;
}
.option_select{
padding: 5px;
padding-top: 0px;
padding-bottom: 10px;
font-size: 13px;
color: #747474;
}
.proposal_status {
position: absolute;
top: 266px;
right: 0px;
margin-right: 1px;
}
.change_status_menu {
border-radius: 5px;
background: rgba(235,235,235, 0.95);
border: 1px solid #d3d3d3;
width: 142px;
height: 110px;
position: absolute;
z-index: 1000;
right: 10px;
bottom: 77px;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
box-shadow: 0px 2px 2px rgba(0,0,0,0.1);
}
.change_status_menu .container{
border: 1px solid white;
padding: 5px;
border-radius: 4px;
}
.change_status_menu .container li {
display: block;
width: 120px;
padding:5px 0 5px 10px;
margin:0;
}
.change_status_menu .container li:hover{
background: -webkit-linear-gradient(top, #ffffff 2%, #e9e9e9 96%, #F3F3F3 85%, #e9e9e9 96%, #ffffff 98%); /* Chrome10+,Safari5.1+ */
border: 1px solid #d7d7d7;
border-radius: 3px;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 9px;
}
.arrow {
z-index: 1003;
border-color: #EDEDED transparent transparent transparent;
border-style: solid;
border-width: 10px;
height:0;
width:0;
position:absolute;
right: 38px;
bottom: 60px;
}
.arrow_border {
z-index: 1001;
border-color: #d3d3d3 transparent transparent transparent;
border-style: solid;
border-width: 10px;
height:0;
width:0;
position:absolute;
right: 38px;
bottom: 58px;
}
.arrow_border_2 {
z-index: 1002;
border-color: #fff transparent transparent transparent;
border-style: solid;
border-width: 10px;
height:0;
width:0;
position:absolute;
right: 38px;
bottom: 59px;
}
.proposal_status .status{
width: 227px;
}
.proposal_status .status .status_header,
.proposal_status .status .Unpublished{
background: #e5e5e5;
background: -webkit-gradient(linear, left bottom, left top,
color-stop(0%,#e5e5e5),
color-stop(96%,#f2f2f2),
color-stop(97%,#ffffff),
color-stop(98%,#e5e5e5)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* Opera11.10+ */
background: -ms-linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-9 */
background: linear-gradient(bottom, #e5e5e5 0%, #f2f2f2 96%, #ffffff 97%, #e5e5e5 98%); /* W3C */
width: 227px;
height: 30px;
}
.proposal_status .status .status_header .change_status{
width: 88px;
font-size: 9px;
float: right;
display: inline-block;
margin: 5px;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
cursor: pointer;
}
.proposal_status .Accepted,
.proposal_status .Declined,
.proposal_status .Open{
margin: 5px;
display: inline-block;
text-transform: uppercase;
font-size: 14px;
color: #848484 !important;
text-shadow:#fff 0px 1px 0, #fff 0 -1px 0;
}
.proposal_status .Accepted .badge,
.proposal_status .Declined .badge,
.proposal_status .Open .badge,
.proposal_status .Unpublished .badge{
width: 17px;
height: 17px;
display: inline-block;
position: relative;
top: 3px;
}
.proposal_status .Accepted .badge{
background: url(/images/header_status_green.png) no-repeat;
}
.proposal_status .Declined .badge{
background: url(/images/header_status_blue.png) no-repeat;
}
.proposal_status .Open .badge{
background: url(/images/header_status_grey.png) no-repeat;
}
.proposal_status .Unpublished .badge{
background: url(/images/header_status_white.png) no-repeat;
}
.proposal_status .status .info{
background: #F2F2F2;
background: -webkit-gradient(linear, left bottom, left top,
color-stop(0%,#F2F2F2),
color-stop(100%,#D6D6D6)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* Opera11.10+ */
background: -ms-linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#F2F2F2', endColorstr='#D6D6D6',GradientType=0 ); /* IE6-9 */
background: linear-gradient(bottom, #F2F2F2 0%, #D6D6D6 100%); /* W3C */
box-shadow: inner 0 2px 2px #bbb;
-moz-box-shadow: inset 0 2px 2px #bbb;
-webkit-box-shadow: inset 0 2px 2px rgba(0,0,0,0.2);
}
.prop-status-details {
padding: 10px;
color: #5F5F5F;
line-height: 15px;
}
.proposal_status .status .Unpublished{
margin-top: 95px;
text-transform: uppercase;
text-indent: 10px;
line-height: 30px;
font-size: 14px;
color: #818181;
text-shadow:#fff 0px 1px 0, #fff 0 -1px 0;
box-shadow: none;
}
.action_button {
font-family: "Lucida Sans Unicode", "Lucida Grande", Arial, Helvetica, sans-serif;
background: #FCFCFC;
border: 1px solid #DCDCDC;
border-radius: 4px;
padding-left: 5px;
padding-right: 5px;
font-size: 10px;
line-height: 18px;
color: #8B8B8B !important;
text-transform:uppercase !important;
/* text-shadow: #555 0px -1px 1px;*/
/* letter-spacing:1px;*/
font-size: 11px;
font-weight: bold;
line-height: 18px;
}
.action_button:hover{
text-decoration: none;
background: #f4f4f4;
border: 1px solid #ccc;
}
The problem is that you're setting the class attribute with html content. I've done a quick workaround:
http://jsfiddle.net/a7rXZ/4/
Simply changing .html() with .text(). The original returns a value that looks like the following (yes, including all the whitespace):
<div class="badge"></div>
Declined
But you're expecting just the text Declined, which is retrievable by the new version. You might like to consider a slightly stronger tactic (whitespace removal would be a start, but I'm referring to something more rigid), even though for now the new version works.

How to make links look like tabs using html/css?

I have this wireframe I am working from: http://problemio.com/wireframe.pdf
I am trying to make the tabbed items that read like "ongoing discussion | suggested solutions | solution history... " to look tabbed as they are on the wireframe.
So far I am able to use JavaScript to show/hide the correct elements, but what I am not sure how to do is highlight the tab that is active, and how to draw the lines surrounding the tab.
Here is an example of what I have so far:
http://www.problemio.com/problems/problem.php?problem_id=179
Even if I make each link a div, how do I toggle between the styling of those divs?
Thanks!!
If you already have the showing and hiding down and are looking for a non-jQuery option you could try something like this:
http://jsfiddle.net/wqEdj/
It's a basic styling of straight anchor elements.
You're easiest bet will be using jQueryUI Tabs. Example here http://jqueryui.com/demos/tabs/
Here is a CSS/JS solution that you can run here to see it in action. JQuery is used, but could easily be replaced with standard JS. No images required.
The source of this solution:
https://css-tricks.com/better-tabs-with-round-out-borders/
Another related example with the tabs under the line can be found here: http://codepen.io/chriscoyier/pen/JozNqX
$(function() {
$("li").click(function(e) {
e.preventDefault();
$("li").removeClass("selected");
$(this).addClass("selected");
});
});
.tabrow {
text-align: center;
list-style: none;
margin: 20px 0 20px;
padding: 0;
line-height: 24px;
height: 26px;
overflow: hidden;
font-size: 12px;
font-family: verdana;
position: relative;
}
.tabrow li {
border: 1px solid #AAA;
background: #D1D1D1;
background: -o-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: -ms-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: -moz-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: -webkit-linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
background: linear-gradient(top, #ECECEC 50%, #D1D1D1 100%);
display: inline-block;
position: relative;
z-index: 0;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.4), inset 0 1px 0 #FFF;
text-shadow: 0 1px #FFF;
margin: 0 -5px;
padding: 0 20px;
}
.tabrow a {
color: #555;
text-decoration: none;
}
.tabrow li.selected {
background: #FFF;
color: #333;
z-index: 2;
border-bottom-color: #FFF;
}
.tabrow:before {
position: absolute;
content: " ";
width: 100%;
bottom: 0;
left: 0;
border-bottom: 1px solid #AAA;
z-index: 1;
}
.tabrow li:before,
.tabrow li:after {
border: 1px solid #AAA;
position: absolute;
bottom: -1px;
width: 5px;
height: 5px;
content: " ";
}
.tabrow li:before {
left: -6px;
border-bottom-right-radius: 6px;
border-width: 0 1px 1px 0;
box-shadow: 2px 2px 0 #D1D1D1;
}
.tabrow li:after {
right: -6px;
border-bottom-left-radius: 6px;
border-width: 0 0 1px 1px;
box-shadow: -2px 2px 0 #D1D1D1;
}
.tabrow li.selected:before {
box-shadow: 2px 2px 0 #FFF;
}
.tabrow li.selected:after {
box-shadow: -2px 2px 0 #FFF;
}
<ul class="tabrow">
<li>Lorem</li>
<li>Ipsum</li>
<li class="selected">Sit amet</li>
<li>Consectetur adipisicing</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

What comboBox or dropDownList is this one?

I'm looking to create a similar combobox or dropdown list like this where the box containing the selection items pops up when "Gold coast" or "Newest" button is click on the right side of the following page:
Deal Zoo
It seems to have a very slick look and feel and I wonder where to get the Javascript or ASP .Net component for this?
I'm the creator of Deal Zoo. Happy to help you out with the dropdown styling. It's a combination of javascript/jquery, css and plain ol' HTML to achieve the result.
You'll need to make sure you have the Jquery library. I use the google hosted version.
The HTML is:
<dl class="dropdown">
<dt><span>Newest<span class="icon"></span></span></dt>
<dd>
<ul style="display: none; ">
<li>Newest</li>
<li>Cheapest</li>
<li>Most Popular</li>
<li>Ending Soon</li>
</ul>
</dd>
</dl>
The CSS is (adapt as needed, the images would obviously need to be created)
.dropdown {
position: relative;
width: 200px;
}
.dropdown dt a {
display: block;
border: 1px solid #A3CFE4;
color: #585858;
background-color: #ececec;
background-image: -moz-linear-gradient(center top, #fefefe, #e9e9e9);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fefefe), to(#e9e9e9));
border-style: solid;
border-color: #ccc;
border-width: 1px;
font-size: 11px;
font-weight: bold;
line-height: 11px;
padding: 5px 0 6px 5px;
text-shadow: 0 0 1px #fff;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
}
.dropdown dt a:hover {
border-color: #b3b3b3;
background-color: #d7d7d7;
background-image: -moz-linear-gradient(center top, #f0f0f0, #dadada);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f0f0f0), to(#dadada));
}
.dropdown dt a:active {
color:#454545;
background: #ccc;
border-color: #bbb;
}
.dropdown dt a span {
cursor: pointer;
padding: 4px 5px 5px;
}
.dropdown dt a span .icon {
background: url(/images/dropdown-arrow.png) no-repeat scroll right center;
width: 14px;
height: 10px;
padding-left: 15px;
}
.dropdown dd ul {
display: none;
list-style: none;
position: absolute;
right: 0px;
top: 0px;
width: auto;
min-width: 170px;
background: white;
-webkit-box-shadow: rgba(0, 0, 0, .5) 0 0 5px;
-moz-box-shadow: rgba(0, 0, 0, .5) 0 0 5px;
box-shadow: rgba(0, 0, 0, .5) 0 0 5px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding: 4px 0px;
z-index: 100;
font-size: 12px;
}
.dropdown dd ul li a {
padding: 2px 10px 2px 20px;
display: block;
color: #333;
}
.dropdown dd ul li a:hover {
color: #fefefe;
background: #3296df;
}
.dropdown dd ul li a.selected {
background: url(/images/tick.png) left 7px no-repeat;
font-weight: bold
}
.dropdown dd ul li a.selected:hover {
background-color: #3296df;
background-position: left -53px;
color: #fefefe;
}
The Javascript is:
$(document).ready(function (){
$(".dropdown dt a").click(function(e) {
e.preventDefault();
$(this).parents(".dropdown").children("dd").children("ul").toggle();
});
$(document).bind('click', function(e) {
var $clicked = $(e.target);
if (! $clicked.parents().hasClass("dropdown"))
$(".dropdown dd ul").hide();
});
});

Categories