My page no longer applies the :hover effect to my .tabs li element, but I can't for the life of me figure out why. I commented out my jQuery script and it still won't work.
Here's a JSFiddle: https://jsfiddle.net/qpmg4wzq/
<div id="tabs-container">
<ul class="tabs">
<li class="tab current" data-tab="tab-1">tab 1</li>
<li class="tab" data-tab="tab-2">tab 2</li>
<li class="tab" data-tab="tab-3">tab 3</li>
<li class="tab" data-tab="tab-4">tab 4</li>
</ul>
</div>
#tabs-container {
float: left;
width: 100%;
overflow: hidden;
}
.tabs {
padding: 0px;
list-style: none;
clear: left;
float: left;
left: 50%;
}
.tabs li {
display: block;
float: left;
right: 50%;
margin: 0;
padding: 10px 20px 5px 20px;
cursor: pointer;
font-size: 1.1em;
line-height: 2em;
-webkit-transition: color .2s linear;
-moz-transition: color .2s linear;
-ms-transition: color .2s linear;
-o-transition: color .2s linear;
transition: color .2s linear;
-webkit-transition: background .2s linear;
-moz-transition: background .2s linear;
-ms-transition: background .2s linear;
-o-transition: background .2s linear;
transition: background .2s linear;
}
.tabs li:hover {
background: #88abc2!important;
}
.tabs li.current {
background: #d0e0eb;
color: #49708a;
}
.tab-content {
display: none;
padding: 15px;
line-height: 1.4;
}
.tab-content.current {
display: inherit;
}
Thanks.
Your .tab-content is overlapping the .tabs-container so any :hover action you make is actually registering as a hover on the .tab-content element.
A couple of options to solve this
Move the tab-content down using margin-top
.tab-content.current {
display: inherit;
margin-top: 60px;
}
Remove float: left from #tabs-container
Related
I have a problem with transitions with my checkbox. All I want to do is to dropdown menu slowly on low width resolution.
Here is my code:
HTML:
<nav class="header-nav">
<input type="checkbox" id="header-nav-button">
<label for="header-nav-button">☰</label>
</input>
<ul>
<li><a class="header-nav-links" id="active">Home</a></li>
<li><a class="header-nav-links about-us">About Us</a></li>
<li><a class="header-nav-links">Our Services</a></li>
<li><a class="header-nav-links">Prices</a></li>
<li><a class="header-nav-links">Contact</a></li>
</ul>
</nav>
Input CSS:
input[type="checkbox"] + label{
font-size: 40px;
cursor: pointer;
color: #ed145b;
font-family: Lato;
font-weight: 700;
line-height: 38px;
padding: 0 20px;}
input, label{
display: none;}
And my CSS code placed in #media (max-width: 600px):
label{
display: inline-block;
}
#header-nav-button{
}
#header-nav-button:not(:checked) ~ul{
display:none;
height: 0;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-ms-transition: all .5s ease;
transition: all 5s ease;
}
}
#header-nav-button:checked ~ ul{
display: block;
height: 200px;
}
#header-nav-button:checked ~ ul li{
display: block;
padding: 0 20px;
}
I tried the trick with height, visibility and opacity - nothing worked for me unfortunatly. It seems that transition is just not working properly.
You can't animate height.
But you CAN animate max-height.
<nav class="header-nav">
<label for="header-nav-button">☰</label>
<input type="checkbox" id="header-nav-button">
<ul>
<li><a class="header-nav-links" id="active">Home</a></li>
<li><a class="header-nav-links about-us">About Us</a></li>
<li><a class="header-nav-links">Our Services</a></li>
<li><a class="header-nav-links">Prices</a></li>
<li><a class="header-nav-links">Contact</a></li>
</ul>
</nav>
I positioned label above input so I can use the more precise + selector in CSS (#header-nav-button + ul)
label {
font-size: 40px;
cursor: pointer;
color: #ed145b;
font-family: Lato;
font-weight: 700;
line-height: 38px;
padding: 0 20px;
}
input,
label {
display: none;
}
#media ( max-width: 600px) {
label {
display: inline-block;
}
ul {
max-height: 0;
overflow: hidden;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-ms-transition: all .5s ease;
transition: all .5s ease;
}
ul li {
padding: 0 20px;
}
#header-nav-button:checked+ul {
max-height: 999px;
}
}
I removed the display attributes because you can't animate display. Instead, I used overflow: hidden to hide the menu.
And I changed height to max-height. The good thing about this, is you don't need to know the exact height of the menu, you can set it to an amount you know it will never reach. This way you're menu can "grow" without you having to figure out its height every time.
https://jsfiddle.net/w4fwbw3s/8/
I have a dropdown menu in SilverStripe that works although when you hover over the space where the downdown part it shows up when I only want it to show up when you hover over the main menu item. I don't really know if that makes sense. I have included my code so you can maybe see what I mean.
CSS
.menu, .menu ul, .menu li, .menu a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
.menu {
height: 40px;
width: auto;
padding: 0;
margin: 0;
float: left;
}
.menu li {
position: relative;
list-style: none;
float: left;
display: block;
}
/* Links 8*/
.menu li a {
display: block;
padding: 0 20px;
margin: 6px 0;
line-height: 28px;
text-decoration: none;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 14px;
color: #f3f3f3;
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
text-transform: uppercase;
}
.menu li:first-child a {
border-left: none;
}
.menu li:last-child a {
border-right: none;
}
.menu li:hover > a {
color: #D12D3C;
}
.menu li > a:hover {
color: #D12D3C;
}
.menu li > a.current {
color: #000;
background-color: #fff;
}
.menu li > a.section {
color: #000;
background-color: #fff
}
/* Sub Menu */
.menu ul {
position: absolute;
top: 40px;
left: 0;
opacity: 0;
background: #1f2024;
text-transform: none;
text-transform: none;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
z-index: 9999;
}
.menu li:hover > ul {
opacity: 1;
}
.menu ul li {
height: auto;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
.sub-menu li:hover {
height: auto;
overflow: visible;
padding: 0;
}
.menu ul li a {
width: 210px;
padding: 4px 0 4px 30px;
margin: 0;
border: none;
border-bottom: 1px solid #353539;
}
.menu ul li:last-child a {
border: none;
}
HTML
<div class="large-12 medium-12 header columns">
<img src="themes/Connected/images/Connected-banner.png" alt="banner" />
</div>
<div class="large-12 medium-12 band columns">
<ul class="menu">
<% control ChildrenOf(Home) %>
<li><a class="$LinkingMode" href="$Link" title="$Title.XML" alt="$Title.XML" style="text-transform:uppercase;">$MenuTitle</a>
<% if Children %>
<ul class="sub-menu">
<!-- Sub Menu -->
<% control Children %>
<li><a class="$LinkingMode" href="$Link" title="$Title.XML" alt="$Title.XML">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>
</li>
<% end_control %>
</ul>
<img src="/themes/Connected/images/search-icon.png" alt="search-icon" />
</div>
We can move the sub menu off screen until it is hovered by adjusting the top value.
CSS
.menu ul {
position: absolute;
top: -100000px;
left: 0;
opacity: 0;
background: #1f2024;
text-transform: none;
text-transform: none;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s, top 0s .35s;
transition: opacity .25s ease .1s, top 0s .35s;
z-index: 9999;
}
.menu li:hover > ul {
opacity: 1;
top: 40px;
-webkit-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
}
Demo
The benefit of doing this instead of hiding and showing the menu with display: none and display: block is this allows us to have a nice css transitions fade the menu in and out.
Try removing "opacity 0;" and change it to "display: none;" and "opacity: 1" to "display: block;". Because the sub menu is actually there even though you can't see it, so it is still being hovered on. This seems to be a pure css issue from what I can see. Hope that helps
I have a footer with content in it. Problem I'm having is the content is displaying vertically instead of horizontally.
I've tried using float:right; that hasn't changed anything. Would really appreciate some help.
Also two of the three social icons aren't showing up. That might be because of the float issue though...
Here's my code
<div class="footer-grid">
<h3>More</h3>
<ul>
<li>FAQ</li>
<li>Privacy Policy</li>
<li>Terms and Conditions</li>
</ul>
</div>
<div class="footer-grid">
<h3>Connect With Us</h3>
<ul class="social-icons">
<li>
<a class="facebook" href="#"> </a>
</li>
<li>
<a class="pinterest" href="#"> </a>
</li>
<li>
<a class="twitter" href="#"> </a>
</li>
</ul>
<p class="copy-right">Website by Elevate design</p>
</div>
Css:
.footer-grid {
min-width: 100%;
float: left;
background-color: #414141;
}
.footer-grid:nth-child(3n+1) {
margin-right: 0;
}
.footer-grid h3 {
color: #3D3D3D;
float: right;
font-size: 14px;
font-family: 'arial';
margin-bottom: 0.8em;
}
.footer-grid ul li {}
.footer-grid ul li a {
color: #8C8C8C;
font-size: 14px;
transition: 0.5s all;
margin-right: 10px;
-webkit-transition: 0.5s all;
-moz-transition: 0.5s all;
-o-transition: 0.5s all;
}
.footer-grid ul li a:hover {
zoom: 1;
filter: alpha(opacity=75);
opacity: 0.7;
-webkit-transition: opacity .15s ease-in-out;
-moz-transition: opacity .15s ease-in-out;
-ms-transition: opacity .15s ease-in-out;
-o-transition: opacity .15s ease-in-out;
transition: opacity .15s ease-in-out;
}
.social-icons li {
display: inline-block;
}
.social-icons li a {
width: 72px;
height: 72px;
display: block;
}
.social-icons li a.facebook {
background: url(../images/facebook_icon.png) no-repeat 0px 0px;
}
.social-icons li a.twitter {
background: url(../images/twitter_.png) no-repeat -56px 0px;
}
.social-icons li a.pinterest {
background: url(../images/pinterest.png) no-repeat -112px 0px;
}
.footer-grid p {
color: #A2A2A2;
font-size: 14px;
line-height: 1.5em;
padding: 0 0 0.4em 0;
}
.footer-grid input[type="text"] {
width: 84%;
margin: 0.4em 0 1em;
padding: 0.8em;
border: 1px solid #C3C3C3;
transition: border-color 0.5s all;
-webkit-transition: border-color 0.5s all;
-moz-transition: border-color 0.5s all;
-o-transition: border-color 0.5s all;
font-family: 'open_sanssemibold';
color: #3D3D3D;
outline: none;
border-radius: 0.5em;
-webkit-border-radius: 0.5em;
-moz-border-radius: 0.5em;
-o-border-radius: 0.5em;
}
.footer-grid input[type="text"]:hover {
border: 1px solid #999;
}
.footer-grid input[type="submit"] {
background: #F36EA7;
padding: 0.8em;
display: block;
width: 100%;
font-family: 'arial';
color: #FFF;
border: none;
font-size: 14px;
border-radius: 0.3em;
-webkit-border-radius: 0.3em;
-moz-border-radius: 0.3em;
-o-border-radius: 0.3em;
outline: none;
cursor: pointer;
transition: 0.5s all;
-webkit-transition: 0.5s all;
-moz-transition: 0.5s all;
-o-transition: 0.5s all;
}
.footer-grid input[type="submit"]:hover {
background: #EE639F;
}
.footer-grids {
padding: 3em 0 5em;
}
.copy-right {
margin-top: 1em;
}
.copy-right a {
color: #A2A2A2;
transition: 0.5s all;
-webkit-transition: 0.5s all;
-moz-transition: 0.5s all;
-o-transition: 0.5s all;
}
.copy-right a:hover {
color: #F36EA7;
}
you forgot to put display:inline-block in .footer-grid ul li
.footer-grid ul li{
display:inline-block;
}
I was expecting this from Internet Explorer, but my beloved Firefox let me down on this one.
This fiddle will not work (at least for me it did not) on Firefox and I would like to know why. I have seen a lot of documentation and I guess this should be working.
Here is the fiddle: http://jsfiddle.net/6UFX7/11300/
HTML:
<div id="nav">
<ul>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
</ul>
</div>
CSS:
#nav
{
height:60px;
background-color:#FFFFFF;
overflow:hidden;
}
#nav ul
{
color: #f2f2f2;
margin-top:20px;
list-style-type: none;
text-align: center;
float:left;
}
#nav ul li
{
display: inline-block;
*display: inline;
zoom: 1;
margin: 0 10px;
}
#nav ul li a
{
color: #8198A0;
font-style: normal;
font-size: 14px;
font-weight: 500;
letter-spacing: 0.25px;
text-transform: uppercase;
text-decoration: none;
-webkit-transition: color 0.5s ease;
-moz-transition: color 0.5s ease;
-o-transition: color 0.5s ease;
transition: color 0.5s ease;
}
#nav ul li a:after
{
margin-top:16px;
content: "";
display: block;
height: 5px;
width: 0;
-webkit-transition: width 0.5s ease, background-color 0.5s ease;
-moz-transition: width 0.5s ease, background-color 0.5s ease;
-o-transition: width 0.5s ease, background-color 0.5s ease;
transition: width 0.5s ease, background-color 0.5s ease;
pointer-events:none;
}
#nav ul li a:hover:after
{
width: 100%;
background-color:#8198A0;
}
#nav ul li a:hover
{
cursor: pointer;
}
One more quick question about "pointer-events:none":
It is working fine on Internet Explorer but not on Chrome (I could not test it on Firefox because the above problem).
Thanks in advance!
This appears to be because the #nav ul li a elements are the default display: inline. Adding display: inline-block; to these elements fixes the issue.
Working Example:
#nav
{
height:60px;
background-color:#FFFFFF;
overflow:hidden;
}
#nav ul
{
color: #f2f2f2;
margin-top:20px;
list-style-type: none;
text-align: center;
float:left;
}
#nav ul li
{
display: inline-block;
*display: inline;
zoom: 1;
margin: 0 10px;
}
#nav ul li a
{
color: #8198A0;
font-style: normal;
font-size: 14px;
font-weight: 500;
letter-spacing: 0.25px;
text-transform: uppercase;
text-decoration: none;
display: inline-block;
-webkit-transition: color 0.5s ease;
-moz-transition: color 0.5s ease;
-o-transition: color 0.5s ease;
transition: color 0.5s ease;
}
#nav ul li a:after
{
margin-top:16px;
content: "";
display: block;
height: 5px;
width: 0;
-webkit-transition: width 0.5s ease, background-color 0.5s ease;
-moz-transition: width 0.5s ease, background-color 0.5s ease;
-o-transition: width 0.5s ease, background-color 0.5s ease;
transition: width 0.5s ease, background-color 0.5s ease;
pointer-events:none;
}
#nav ul li a:hover:after
{
width: 100%;
background-color:#8198A0;
}
#nav ul li a:hover
{
cursor: pointer;
}
<div id="nav">
<ul>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
<li><a>ENTRY</a></li>
</ul>
</div>
As for the pointer-events issue, if this does not solve that issue as-well, you should probably ask a question specifically about that.
I'm trying to get rid of the flickering I'm getting after I added negative top margin (so that it would be visible above my navbar) to my < li > item. Here's the JSFiddle's link: http://fiddle.jshell.net/xv6mk/.
And the code just in case.
HTML:
<ul>
<li>Main</li>
<li>Subpage 1</li>
<li>Subpage 2</li>
<li>Subpage 3</li>
<li>About</li>
</ul>
And CSS:
ul {
display: inline;
list-style: none;
}
li {
font-size: 16px;
display: inline-block;
margin-right: -6px;
padding: 16px;
cursor: pointer;
display:inline-block;
-webkit-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
-ms-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
transition: all 0.4s ease;
}
li:hover {
background: white;
color: #74DF00;
border-top: 10px solid #525458;
margin-top: -10px;
}
I will really appreciate help :) .
EDIT: Adding this 2 lines to < li > item (not only hover) works like charm. Thank you :) .
border-top: 10px solid #848484;
margin-top: -10px;
The problem is the transition property, you are transitioning everything, try the following:
transition-property: color, border-top, background;
Just add the prefixes for cross browser support.
Fiddle: http://fiddle.jshell.net/xv6mk/3/