I have a nav bar made up of png icons. When resizing a page or displaying on other windows, the icons do not move so get cut off. I cannot find a way to resize the icons on different screens and make the icons white on hover? I know as they are .png’s I may have to create all of the icons in white aswell?
Anyway you can see it live at http://www.ssangar.com/
Here is my code for the nav:
http://cdpn.io/msjzi
Thanks in advance!
I'm not quite sure if I understand your question 100%, but just as Racil put it, you want to create a css, and set it to a percentage or with pixels...
If you want to add some transformations, I use this code on my website:
nav li a:hover, nav li a.current {
color: #0099CC;
-o-transition: background 0.3s linear 0s, color 0.3s linear 0s;
-webkit-transition: background 0.3s linear 0s, color 0.3s linear 0s;
-ms-transition: background 0.3s linear 0s, color 0.3s linear 0s;
-moz-transition: background 0.3s linear 0s, color 0.3s linear 0s;
transition: background 0.3s linear 0s, color 0.3s linear 0s;}
The reasoning behind all the different transitions is for the all the old browsers that do not accept the transition code.
*Note: You will need to supply more nav info in your css code, the above is to only make it have a transition effect..*
Depending on what you're trying to achieve, instead of creating another set of icons in white, you probably can use opacity alpha layer. Check this tutorial. Here are the basics:
.myMenuItem:hover
{
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
As for the resizing, you can simply set the size to percentage:
.myMenuItem
{
width: 30%;
height: 20%;
}
You can also use transition or transform to add some effects:
transform: scale(.5);
transition:width 0.5s ease;
Related
i have some logos which transition on hover but i've always tested with chrome(yeah i messed up)So I just tested it in ff & ie and it's not working (i have the latest versions)
Here is my fiddle http://jsfiddle.net/r6qZw/
and here is the html
<a id="facebook" href="http://facebook.com"></a>
and the css
#facebook {
float: left;
height: 40px;
width: 40px;
background-image: url(http://i.imgur.com/2lAKpSi.jpg);
background-repeat: no-repeat;
background-position: center center;
-o-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
-khtml-transition: all 0.3s linear;
-webkit-transition: all 0.3s linear;
-ms-transition: all 0.3s linear;
transition: all 0.3s linear;
}
#facebook:hover {
background-image: url(http://i.imgur.com/L7Jmol5.jpg);
}
I know the solution to this is simple but i just couldn't do it. When i remove the background image and just use a color instead, it works but using background image just stops the animation. I still get the second image but it doesn't transition with an animation. I've also tried giving a parent element (like the famous "ul li a" and such)
Can someone help a noob out?
background-image is not a transitionable property (except for gradients, and that's not supported in Chrome - IE supports it though!)
The fact that Chrome can transition the image for you is simply an extension of the standard. This is evidenced by how horrible it looks if you rapidly move your mouse over and off of it repeatedly - normal transitions are smooth in spite of this, but the image "transition" is horrible.
I have a div with fixed height and width and upon clicking the label(checkbox trick) I expand the div to 100% width and height. That works, however the issue is in the transition.
I wish to create a easing transition where first the width expands and then the height expands. However upon defining the transitions the easing doesn't happen, instead it's like transition timing function goes to step-end. The transition happens instantly without easing(even though the delay on height transformation works).
tl;dr: The transition loses smoothness
Example: jsFiddle
The properties can not be transitioned from different "metrics".
In the base state, you specify height in px; in the changed state, you specify it in percentage. That won't work.
You can set it to work somehow with some tricks, that are not fully satisfactory; the best of them is to use max-height to do the change
#cbox {
display:none;
}
.someDiv {
background: blue;
color: white;
width: 200px;
max-height: 100px;
overflow: hidden;
height: 100%;
transition-property: width, max-height;
transition-duration: 2000ms;
transition-timing-function: ease;
transition-delay: 0, 2000ms;
}
#cbox:checked + div {
width: 100%;
max-height: 1000px;
}
I have also writen the transition in a way that can save you some typing when using multiple properties; notice that I can write ease only once
fiddle
You should separate properties with comma, instead of writing them in same line, try this
CSS
-webkit-transition: width 200ms ease 0s, height 200ms ease 200ms;
-moz-transition: width 200ms ease 0s, height 200ms ease 200ms;
-ms-transition: width 200ms ease 0s, height 200ms ease 200ms;
-o-transition: width 200ms ease 0s, height 200ms ease 200ms;
transition: width 200ms ease 0s, height 200ms ease 200ms;
I'm using vendor prefixed css transitions, based on this demo, which seems to only be working in Chrome 22+ at the moment. I'm trying to turn the buttons (Home, Contact, About) into drop-down menus on hover. I want to avoid using javascript and see if I can do it all with CSS.
It fades in if I have the z-index set to a low number (-999) and on hover change it to a high number (999), and change the opacity from 0 to 1 using a transition.
nav > div div {
z-index: -999;
opacity: 0;
-webkit-transition: opacity 1s ease-in-out;
}
nav > div:hover div {
z-index: 999;
opacity: 1;
}
See the Fiddle here.
The problem is it won't fade back out. If I change the transition to also delay the z-index from changing then it will fade out, but not in (-webkit-transition: opacity 1s ease-in-out, z-index 0 linear 1s). Modifications to the Fiddle here.
Essentially what's going on is the opacity fading works fine, but z-index moves too quickly in either one direction or the other. If I don't use z-index at all, then it will open the menu when I'm hovering below the "Hover Me" button instead of on it. Here's another Fiddle showing that scenario.
Is there a way to have one transition for going from point A to point B, and another transition for going from point B to point A? I've played around with putting a separate transition on the :hover element but as far as I can tell it just overrides the first one (as if there is no transition from "not hovering" to "hovering").
TL;DR: Is there a way to modify this, this, or this to make a smooth transition when hovering on (not just near) the "Hover Me" button (without using javascript)?
Check out this Fiddle. Not sure if it does what you want, but I changed the following...
CSS
nav > div > div {
z-index: -999;
position: absolute;
opacity: 0;
-webkit-transition: opacity 1s ease-in-out, z-index 0 linear 1s;
-moz-transition: opacity 1s ease-in-out, z-index 0 linear 1s;
-ms-transition: opacity 1s ease-in-out, z-index 0 linear 1s;
-o-transition: opacity 1s ease-in-out, z-index 0 linear 1s;
}
nav > div:hover > div {
z-index: 999;
opacity: 1;
-webkit-transition: opacity 1s ease-in-out, z-index 0 linear 0;
-moz-transition: opacity 1s ease-in-out, z-index 0 linear 0;
-ms-transition: opacity 1s ease-in-out, z-index 0 linear 0;
-o-transition: opacity 1s ease-in-out, z-index 0 linear 0;
}
I've added transitions to the hover state as well, but with a delay of 0.
I'm creating a simple web page and I'm having trouble adding a fade animation to the css when the background image is changed. I know I need to use something along these lines but whenever I try it, it doesn't seem to work...
-webkit-transition: background 1s ease-in-out;
-moz-transition: background 1s ease-in-out;
-o-transition: background 1s ease-in-out;
-ms-transition: background 1s ease-in-out;
transition: background 1s ease-in-out;
I'll put a link to my css and html below, if anyone could take a look, I would be very grateful :)
CSS: http://pastebin.com/9k1tSiAE
HTML: http://pastebin.com/2K7GFWjN
The problem is you are changing the background image in addition to simply changing properties on the background itself. I've setup a fiddle with some random background tiles. You'll see the background slides but the image changes immediately without a transition:
http://jsfiddle.net/jimjeffers/a2jAF/
You'll need to settle on one image for the background but right now you have three:
background-image:url(nav-bg-initial.png);
background-image:url(nav-bg-secondry.png);
background-image:url(nav-bg-tertiary.png);
You'd need to condense those into one sprite. But once you apply a transition to background and adjust the background position, the background slides rather than fades. So depending on the effect you're going for - transitioning the background may not be the best option for you.
Instead -- what you may need to do is use some nested empty container elements. It's not semantically nice but it could achieve what you want if you want to use CSS transitions to perform a cross fade.
<ul id="navigation-list">
<li><a class="navigation-button" id="nav-button-1" href="#">HOME</a><span class="initial"></span><span class="secondary"></span><span class="tertiary"></span></li>
...
</ul>
The CSS then would be:
.navigation-button { position: relative; }
.initial, .secondary, .tertiary {
bottom: 0;
left: 0;
opacity: 0;
position: absolute
right: 0;
top: 0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
z-index: -1;
}
.initial { background-image:url(nav-bg-initial.png); }
.secondary { background-image:url(nav-bg-secondry.png); z-index: -2; }
.tertiary { background-image:url(nav-bg-tertiary.png); z-index: -3; }
And then you'd toggle their appearances like this:
#navigation-buttons:hover #nav-button-1 .tertiary { opacity: 1; }
It's a bit more work but you'd have to do something along those lines to cross fade different background images at various positions without getting a slide effect.
Using CSS3 transitions, it's possible to have a 'smooth up' and 'smooth down' effect to whatever property.
Can I have it setup to have only a 'smooth down' effect? I'd like the solution to be in CSS only, avoiding JavaScript if possible.
Logic flow:
User clicks element
Transition takes 0.5s to change background color from white to black
User lets go of the mouse left button
Transition takes 0.5s to change background color from black to white
What I want:
User clicks element
Transition takes 0s to change
User lets go of mouse button
Transition takes 0.5s to change...
There's no 'transition-in' time, but there's a 'transition-out' time.
I tried the following in the CSS3 Tryit Editor and it worked in Chrome (12.0.742.60 beta-m).
/* transition out, on mouseup, to white, 0.5s */
input
{
background:white;
-webkit-transition:background 0.5s;
-moz-transition:background 0.5s;
-ms-transition:background 0.5s;
-o-transition:background 0.5s;
transition:background 0.5s;
}
/* transition in, on click, to black, 0s */
input:active
{
background:black;
-webkit-transition:background 0s;
-moz-transition:background 0s;
-ms-transition:background 0s;
-o-transition:background 0s;
transition:background 0s;
}
<input type="button" value="click me to see the transition effect!">
using "transition:none" works also :
div{
background: tomato;
transition: background 0.3s ease-in;
}
div:active{
background: blue;
transition: none;
}
<div>click me</div>