CSS transition effect isn't working - html

I'm quite a newbie to CSS and HTML, and have run into a problem that has me completely stumped - the transition effect I've applied to my navigation bar doesn't seem to be taking effect. I've searched for an answer to no avail, and feel ready to break something at this point. Below is my CSS for the navigation bar.
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
text-align: center;
}
li {
display: inline-block;
font-family: 'Oswald Light', Verdana, Geneva, sans-serif;
font-size: 20px;
background-color: #333;
-webkit-transition: all 0.9s ease;
-moz-transition: all 0.9s ease;
-o-transition: all 0.9s ease;
-ms-transition: all 0.9s ease;
transition: all 0.9s ease;
}
li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover {
background-color: #6699cc;
}

You need to add the transition rules to li a - this is the element that is changing color, not the li!
See here http://jsbin.com/lufujuzuti/edit?html,css,output

You should replace your transition code to li a{}
So it'll be smth like this:
li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
-webkit-transition: all 0.9s ease;
-moz-transition: all 0.9s ease;
-o-transition: all 0.9s ease;
-ms-transition: all 0.9s ease;
transition: all 0.9s ease;
}

Your CSS edited :
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
text-align: center;
}
li {
display: inline-block;
font-family: 'Oswald Light', Verdana, Geneva, sans-serif;
font-size: 20px;
background-color: #333;
}
li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
-webkit-transition: all 0.9s ease;
-moz-transition: all 0.9s ease;
-o-transition: all 0.9s ease;
-ms-transition: all 0.9s ease;
transition: all 0.9s ease;
}
li a:hover {
background-color: #6699cc;
}

Related

Why is my navigation menu not showing up?

I am working on a website with some friends for fun and we are having an issue with the nav menu not showing up after we press the button, I had to use flexbox to align my hamburger menu to the navbar originally, but now when we press it, it isnt showing any of the sub menus at all.
Yes, we realize that webkit is for scss, it was just there for examples
.topnav {
flex-grow: 1;
max-height: 100px;
}
.navbarItems a {
float: left;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 24px;
}
.navbarItems a:hover {
background-color: darkgray;
color: black;
}
.navbarItems a.active {
background-color: white;
color: white;
}
.container {
display: flex;
flex-wrap: wrap;
align-items: center;
background-color: grey;
}
/* Hambuger Menu */
.burger {
background: none;
outline: 0;
cursor: pointer;
border-top: 4px solid currentColor;
width: 28px;
transition: border-top 0.1s ease-in-out;
-webkit-transition: border-top 0.1s ease-in-out;
}
.burger::-moz-focus-inner {
border: 0;
padding: 0;
}
.burger:before {
content: "";
display: block;
border-top: 4px solid currentColor;
width: 100%;
margin-top: 5px;
transition: -webkit-transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out, -webkit-transform 0.5s ease-in-out;
-webkit-transition: -webkit-transform 0.5s ease-in-out;
}
.burger:after {
content: "";
display: block;
border-top: 4px solid currentColor;
width: 100%;
margin-top: 5px;
transition: -webkit-transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out, -webkit-transform 0.5s ease-in-out;
-webkit-transition: -webkit-transform 0.5s ease-in-out;
position: relative;
align-self: center;
}
.burger-check {
display: none;
}
.burger-check:checked ~ .burger {
border-top: 4px solid transparent;
transition: border-top 0.5s ease-in-out;
-webkit-transition: border-top 0.5s ease-in-out;
}
.burger-check:checked ~ .burger:before {
transform: rotate(-405deg) translateY(1px) translateX(-3px);
-webkit-transform: rotate(-405deg) translateY(1px) translateX(-3px);
transition: -webkit-transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out, -webkit-transform 0.5s ease-in-out;
-webkit-transition: -webkit-transform 0.5s ease-in-out;
align-self: center;
}
.burger-check:checked ~ .burger:after {
transform: rotate(405deg) translateY(-4px) translateX(-5px);
-webkit-transform: rotate(405deg) translateY(-4px) translateX(-5px);
transition: -webkit-transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out;
transition: transform 0.5s ease-in-out, -webkit-transform 0.5s ease-in-out;
-webkit-transition: -webkit-transform 0.5s ease-in-out;
}
.navigation {
overflow: hidden;
background-color: black;
max-height: 0;
-webkit-transition: max-height 0.5s ease-in-out;
transition: max-height 1.5s ease-in-out;
}
.burger-check:checked ~ .navigation{
overflow: visible;
background-color: purple;
max-height: 100%;
-webkit-transition: max-height 1s ease-in-out;
transition: max-height 1s ease-in-out;
}
p {
background-color: floralwhite;
font-family: 'Libre Baskerville', serif;
font-size: 30px;
text-align: center;
}
body {
background-color: floralwhite;
font-family: 'Libre Baskerville', serif;
font-size: 30px;
text-align: centeR;
}
h1 {
font-family: 'Libre Baskerville', serif;
font-style: italic;
text-align: center;
}
a {
color: inherit;
}
ul {
margin: 0;
padding: 0;
}
li {
list-style: none;
font-size: 25px;
padding: 5px 0;
}
li a {
text-decoration: none;
}
li a:hover {
text-decoration: underline;
}
.img {
width:1000px;
height:400px;
}
.header {
width: 322px;
height: 219px;
}
h4 {
font-family: 'Libre Baskerville', serif;
text-align: center;
list-style: square;
}
<div class="topnav" id="myTopnav">
<div class="navbarItems">
Home
About
</div>
</div>
<input class="burger-check" id="burger-check" type="checkbox">
<label for="burger-check" class="burger"></label>
</div>
<nav id="navigation1" class="navigation">
<ul>
<li><h1>Professional Awards</h1></li>
<li>Advisor of the Year Award</li>
<li>Emerging Advisor of the Year Award</li>
<li>Emerging Professional of the Year Award</li>
<li>Hall of Fame Award</li>
<li>Outstanding Service Award</li>
<li>Student of the Year</li>
<li><h1>Service Learning Awards</h1></li>
<li>Community Service Award</li>
<li>Environmental Action Awareness</li>
<li>Safety Awareness Award</li>
<li>Service Learning Individual Award</li>
<li>Special Olympics Award</li>
<li><h1>Special Recognition Awards</h1></li>
<li>BPA Marketing and Public Relations</li>
<li>BPA Merit Scholar</li>
<li>Chapter Activities Award of Excellence</li>
<li>Membership Explosion Award</li>
<li>Recruiter of the Year Award</li>
<li>Social Media Award</li>
<li>The Professional Cup</li>
</ul>
</nav>

Transitions on pseudo-elements not working on firefox browser

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.

Proper way of styling links on other page

My main navigation bar is like this: JSFIDDLE
<div id="navbar">
<ul>
<li>Home</li>
<li>Bio</li>
<li>Projects</li>
<li id="active">Contact</li>
<li>Friends</li>
</ul>
</div>
The css for it is as follow:
#navbar {
float: left;
height: 100px;
width: 395px;
background-color: orange;
background-color: #CCCCCC;
background-image: url(../images/1_03.jpg);
}
#navbar ul{
list-style-type: none;
margin-top: 30px;
}
#navbar li{
float: left;
text-align:center;
width: 60px;
}
#navbar a:link, a:visited {
display: block;
width: 100%;
height: 50px;
font-size: 14px;
color: rgba(141,141,141,1);
text-decoration: none;
padding-top: 20px;
font-family: Raleway, sans-serif;
-moz-transition: background-color 0.3s ease;
-webkit-transition: background-color 0.3s ease;
transition: background-color 0.3s ease;
font-weight: 500;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
-ms-transition: all 0.3s linear;
-o-transition: all 0.3s linear;
transition: all 0.3s linear;
}
#navbar a:hover, a:active {
color:white;
background-color: #ff7200;
}
#active > a {
display: block;
color: white;
background-color: rgba(51,51,51,1);
}
Now I have on contact page my icon images, which links to the user's profile on Facebook, Twitter, etc., but they get the same background when in active state like my navigation bar. How can I change that?
I think your problem is in your way of defining css :
#navbar a:hover, a:active should be #navbar a:hover, #navbar a:active

Using different browsers makes my nav bar slightly change?

I built my website mostly checking Google chrome to make sure everything was correct. With my nav bar in Google chrome it is perfect, however, when in IE or Fire Fox the dimensions are changed and they do not fit together correctly.
My website is noahtarr.com
CSS:
nav {
margin-top: -1px;
position: relative;
top: 0;
left: 0;
}
nav a {
margin-left: -3px;
margin-right: -1px;
padding: 10px 20px;
outline: none;
border-right: none;
border-bottom: none;
font-family: arial;
font-weight: bolder;
vertical-align: top;
text-decoration: none;
font-size: 13px;
line-height: 21px;
cursor: pointer;
background-color: #D1DBBD;
color: #3E606F;
-webkit-transition: all .9s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
-webkit-transition: background-color .3s ease;
-moz-transition: background-color .3s ease;
-ms-transition: background-color .3s ease;
-o-transition: background-color .3s ease;
transition: background-color .3s ease;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
nav a:hover {
background-color: #91AA9D;
color:#193441;
-webkit-transition: background-color .3s ease;
-moz-transition: background-color .3s ease;
-ms-transition: background-color .3s ease;
-o-transition: background-color .3s ease;
transition: background-color .3s ease;
}
nav a:first-child {
border-radius: 6px 0 0 0px;
}
nav a:last-child {
border-radius: 0 6px 0px 0;
}
nav a.active {
color: #193441;
border-radius: 8px 8px 0px 0px;
padding-top: 5px;
}
nav a.adjacent-active-left {
border-radius: 0px 8px 0px 0px;
}
nav a.adjacent-active-right {
border-radius: 8px 0px 0px 0px;
}
HTML:
<nav>
<a class="active" href="home.htm">Home</a>
<a class="adjacent-active-right" href="about.htm">About</a>
Services
Portfolio
Contact
</nav>

Remove margin/padding/space beneath label

On this picture you see a label beside a a-link.
CSS for both:
.btn {
zoom: 1;
vertical-align: baseline;
cursor: pointer;
text-align: center;
text-decoration: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background: #666;
color: #fff;
display: inline-block;
padding: 10px 15px;
text-align: left;
font-size: 1em;
border: 0;
margin: 0;
-webkit-transition: background 0.2s ease-in-out;
-moz-transition: background 0.2s ease-in-out;
-ms-transition: background 0.2s ease-in-out;
-o-transition: background 0.2s ease-in-out;
transition: background 0.2s ease-in-out;
}
How to remove the space beneath the label?
The problem was the line-height.
.btn {
line-height: 1.4em;
}