eskrimador 0 Newbie Poster

Hi Everyone,

I am trying to achieve something without the usage of jQuery. Can be done with it but want to find a solution with only css pseudo classes.

So here's what I have so far. A tabbed UI which opens a dropdown menu with a click action using the :target pseudo class. So far so good. The 2nd tab opens as expected.

Here's what I am trying to solve. I want the drop down to close once the focus is taken off of it. The same behavior you would get if the UI was a hover state but still be able to keep the click css function. In short, click to open dropdown and a onmouseout type behavior to close the menu but without javascript.

The dropdown closes when a link within the dropdown is clicked or another tab is clicked and that part of the behavior is correct but don't want to have to have the user do that just to close the dropdown.

Possible? Been trying to solve this for about 1.5 weeks now and starting to think I/We will have to stick to using javascript. Here's my test code below ....

<!doctype html>
<!-- -->
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
  <meta charset="utf-8">

  <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
       Remove this if you use the .htaccess -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  <!-- Mobile viewport optimized: -->
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
  <script src="js/libs/modernizr-1.7.min.js"></script>

	div.items ul:not(:target) {display:none;}
	div.items ul:target {display:block;} 
	div.items ul:not(:active) {display:none;}
	div.items ul:target {display:block;}
	.tabs {
		border:solid 1px #cccccc;
	a {
	.tabs a {
		margin:8px 5px 5px 5px;
	ul {
		padding:10px 0px 10px 0px;
		margin:-8px 0px 0px 222px;
	li {
		border-left:#cccccc solid 1px;
		border-right:#cccccc solid 1px;
		border-bottom:#cccccc solid 1px;
	ul li a {
<!-- Start Tabs -->
	<div class="tabs">
	  <a href="#">Dashboard</a>
	<div class="tabs">
	  <a href="#item2">Data &amp; Reports</a>
	<div class="tabs">
	  <a href="#">Data Archives</a>
<!-- End Tabs -->

<!-- Start 2nd Tabs Content -->
	<div class="items">
		<ul id="item2">
				<a href="#">Sales By Device</a>
				<a href="#">Delivery</a>
				<a href="#">Revenue</a>
				<a href="#">Sales By Purchase Type</a>
				<a href="#">Data Archives</a>
<!-- End 2nd Tabs Content -->

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.