css3 - Add 2nd hover selector -


hi have created menu. added active class when user clicks on menu icon highlights "li" page linked to.

i hover selector called before sign in. background colour of ul has been added.

my question is, able add second hover selector when signing in , changing background of ul without changing properties set before user signs in.

can without adding css class. ::before or ::after or .active:hover. trick?

.menucolumn #nav ul li a.active {   background: #029ef1;   box-shadow: 0px 3px 0px #0175b2;   color: #fff; } .menucolumn #nav ul {   list-style-type: none;   margin: 0;   padding: 0;   background: #e6e7e9; } 

jsfiddle demo

snippet demo:

 .example1 {     width: 20%;   }   .example1 #nav ul {     list-style-type: none;     margin: 0;     padding: 0;     background: #e6e7e9;   }   .example1 #nav ul li {     list-style: none;     display: block;     position: relative;     text-align: left;     border-bottom: 1px solid #cdced0;   }   .example1 #nav ul li:last-child {     border-bottom: none;   }   .example1 #nav ul li {     text-decoration: none;     color: #7e7f81;     line-height: 3em;     display: block;     padding-left: 15‌​px;     font-weight: bold;   }   .example1 #nav ul li a:hover {     background: #7e7f81;     color: #fff;     box-shadow: 0px 3px 0px #dbdcdd;   }   .example1 #nav ul li a.active {     background: #029ef1;     box-shadow: 0px 3px 0px #0175b2;     color: #fff;   }   .example1 #nav ul li a:not(.active) {     background: #000;     box-shadow: 0px 3px 0px #0175b2;     color: #fff;   }
<body>    <div class="example1">      <div id="nav" style="padding-top: 4em;">        <ul>          <li><a href="test.html" target="_self" title="#">example 1</a>          </li>          <li><a href="#" target="_self" title="#">example 1</a>          </li>          <li><a href="#" target="_self" title="#">example 1</a>          </li>        </ul>      </div>    </div>  </body>

when ul containing .active-class have use javascript change uls background:

the fiddle

$(".active").parents("ul").css( "background" , "yellow" );
 .example1 {       width: 20%;   }   .example1 #nav ul {       list-style-type:none;       margin:0;       padding:0;       background:#e6e7e9;   }   .example1 #nav ul li {       list-style: none;       display: block;       position: relative;       text-align: left;       border-bottom:1px solid #cdced0;   }   .example1 #nav ul li:last-child {       border-bottom:none;   }   .example1 #nav ul li {       text-decoration:none;       color:#7e7f81;       line-height:3em;       display:block;       padding-left:15‌px;       font-weight:bold;   }   .example1 #nav ul li a:hover {       background:#7e7f81;       color:#fff;       box-shadow:0px 3px 0px #dbdcdd;   }   .example1 #nav ul li a.active {       background:#029ef1;       box-shadow:0px 3px 0px #0175b2;       color:#fff;   }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <body>    <div class="example1">    <div id="nav" style="padding-top: 4em;">        <p>ul .active-link in it:</p>        <ul>          <li><a href="#" target="_self" title="#">example 1</a></li>          <li><a href="test.html" target="_self" title="#" class="active">active class</a></li>          <li><a href="#" target="_self" title="#">example 1</a></li>          <li><a href="#" target="_self" title="#">example 1</a></li>        </ul>        <p>ul without .active-link in it:</p>        <ul>          <li><a href="#" target="_self" title="#">example 1</a></li>          <li><a href="test.html" target="_self" title="#">example 1</a></li>          <li><a href="#" target="_self" title="#">example 1</a></li>          <li><a href="#" target="_self" title="#">example 1</a></li>        </ul>          </div>      </div>  </body>


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -