html - Making FA change color on :hover with <li> -
i'm working on basis of side navigation bar enabled old hamburger button.
/* * navigation menu * hambuger open * */ .navigation-container { height: 100%; width: 240px; background: #ffffff; border-right: 2px solid #252525; position: fixed; top: 0; left: 0; } .navigation { width: 80%; padding: 0; margin: 0; margin-left: 10px; } .navigation ul { margin: 0; padding: 0; margin-top: 90px; margin-left: 20px; } .navigation ul li { /* setting area */ list-style: none; margin: 0 auto; padding: 20px 0px; /* typography changes */ text-decoration: none; color: #dddddd; font-size: 14px; font-weight: 600; letter-spacing: 1.5px; /* styling */ border-bottom: 1px solid #dddddd; -webkit-transition: .25s ease-in-out; -moz-transition: .25s ease-in-out; -o-transition: .25s ease-in-out; transition: .25s ease-in-out; } .navigation ul .fa { padding: 0; margin: 0; padding-right: 5px; font-size: 20px; color: #dddddd; } .navigation-container, .navigation li, > li { color: #252525; } .navigation ul li:hover { padding: 35px 0px; color: #252525; -webkit-transition: .25s ease-in-out; -moz-transition: .25s ease-in-out; -o-transition: .25s ease-in-out; transition: .25s ease-in-out; }
<!doctype html> <html> <head> <meta charset="utf-8"> <title>aaron ward's portfolio</title> <!-- stylesheet links --> <!-- font awesome --> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <!-- open sans typeface import --> <link href='http://fonts.googleapis.com/css?family=open+sans:400,700,800,600' rel='stylesheet' type='text/css'> <!-- personal stylesheets --> <link rel="stylesheet" href="css/style.css"> </head> <body> <!-- navigation start --> <div class="navigation-container"> <div class="navigation"> <ul> <a href=""> <li> <i class="fa fa-home fa-fw"></i></span> home </li> </a> <a href=""> <li> <i class="fa fa-connectdevelop fa-fw"></i> work </li> </a> <a href=""> <li> <i class="fa fa-user fa-fw"></i> about </li> </a> <a href=""> <li> <i class="fa fa-envelope fa-fw"></i> contact </li> </a> </ul> </div> </div> </body>
as can see when hovering on [ul li] element's, font-awesome icon not changing color.
i have tried adding following (results didn't work):
.navigation ul li:hover, .navigation ul .fa:hover { padding: 35px 0px; color: #252525; -webkit-transition: .25s ease-in-out; -moz-transition: .25s ease-in-out; -o-transition: .25s ease-in-out; transition: .25s ease-in-out; } .navigation ul .fa:hover { color: #252525; }
but wouldn't work want whole area effect both elements (fa &
so ultimately: how make both text , font awesome icon change color when hovering on respected ul li element
there problem markup, <a>
should inside <li>
. , <li>
must directly under <ul>
, can fix once.
a:hover { color: red; } /* if above code didn't work a:hover, a:hover .fa { color: green; } */ /* if above code didn't work a:hover, a:hover .fa::before { color: blue; } */
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <ul> <li> <a href="#"> <i class="fa fa-home fa-fw"></i> home </a> </li> </ul>
Comments
Post a Comment