I am making a solar system in CSS, and here is my code: http://jsfiddle.net/kAKdm/.
However, it seems that :hover will only work with the sun which is the only item which does not move with CSS animations.
Does anyone know a way to make the :hover work with the planets also? I want to do something like this, but it will of course be overridden by the animation:
#planets > div:hover {
-webkit-transform: scale(1.2);
}
Thanks in advance.
Basicaly if you are scaling the planets you are changing it's width, height, top, left, border-radius properties.
scale sure is handy but since you override the transform you could try this:
#planet-venus:hover {
width:20px;
height:20px;
left: 396px;
top: 290px;
border-radius:10px;
}
You will have to calculate the width height and reposition each planet by half the ammount of scale but it works.
http://jsfiddle.net/kAKdm/21/ - try hover venus.
Chrome doesn't accept div:hover, it only accepts img:hover. So instead of #planets > div:hover, use:
#planets > div img:hover
For more details visit: http://dinolatoga.com/2009/09/18/amazing-imag-hover-effects-with-webkit-and-css/
Related
I've implemented a CSS solution to animate a style that is set inline with the guidance from CSS-Tricks. Also used help from SO to have the text blend with CSS
I have the animation of the label going both ways (on load and reset) but the progress bar itself immediately goes to Zero
The width of the div gets set inline like this:
<div class="progress-black" ng-style="{width:progress}"></div>
And the onload animation is simple
.progress-black {
background: black;
animation: progress-bar .5s linear;
z-index: 2;
}
#keyframes progress-bar {
0% { width: 0; }
}
Here is my jsfiddle
It seems like #keyframe animations need a 100% value, which is set dynamically, so not sure how to express that in CSS.
My particular app has the ability for a user to click 'reset'. Is there a way to have the animation happen back to 0?
You have few problems in your code and there is two solutions for you:
first solution: - and the better one
in your case there is no need to use animation, its enough if you will use transition: width 2s; - and you should do that.
you checking if the value "exist" with if (scope.value) and when you reset the width of the progress remain as it was and not changed
you adding .zero class that color
see here
second solution:
1.. in your case there is no need to use animation, its enough if you will use transition: width 2s; - and you should do that.
2.. if you have zero class set .progress-black { width: 0 !important; } so the width will be 0 (important because you want it to be stronger then the inline css).
see here
I'm not sure what in the CSS is causing the * to display below the textbox when I add the class tiny to the div
<div class="editor-field tiny required-indicator">
Check out the jsfiddle: https://jsfiddle.net/pfqqmmfn/
If the class tiny is removed then the * display after the textbox like expected. I'm still learning CSS so any help would be great. I know it has to be something simple but I can't find the issue.
Thanks for any help.
I updated your JSFiddle: https://jsfiddle.net/pfqqmmfn/2/
I changed .required-indicator:after (the little asterisk) to this:
.required-indicator:after
{
content: "*";
display:block;
font-weight: bold;
color: Red;
width:20px;
height:20px;
position:absolute;
left:calc(100% + 10px);
top:0;
}
And added position:relative; to your .tiny class.
Relative position to the parent (.tiny) lets me use position:absolute on its :after pseudo-element (which behaves as its child).
You had your asterisk pseudo-element on position:relative; so by giving that item the .tiny class, you set its width to 135px (with !important, too) thus stopping the little asterisk from fitting in there.
If you add this
form div.tiny {
width: 120px !important;
}
it overwrites the built-in rule that causes your problem (making the input field containers too narrow to allow the asteriks next to it). You can try and use different width settings.
https://jsfiddle.net/zLoqy3py/
I've been trying to create a transition effect where, on hover, a sub menu slides out from underneath the main navigation bar. So far, I've got all the elements in place and wasted HOURS playing around with different methods from various posts, but to no avail.
Here is the JSFiddle.
I'm guessing I'm gonna have to get rid of display: none -> display: block way of hiding the submenu as its no good for transitions but various other methods such as transitioning max-height, opacity, pulling it down from a massive top value etc have failed. With the inflated top value method, the submenu slides over everything rather than under and changing z-index values somehow pushes it behind EVERYTHING while turning the background transparent. Very weird behaviour.
I would greatly appreciate it if someone could explain to me how to go about creating a smooth slide-out transition for the sub-menu.
Thank You
Transforming the scale or transitioning the max-height: 0 is a better option for navigational elements.
JSFiddle
If the initial state of the element is "display: none" it is passed over in the DOM which will hide that element (as well as any children) from assistive technology.
Also, you can use a sibling sectors to select .dropdown, instead of overly nesting elements
Adjacent sibling: .dropbtn:hover + .dropdown_content
Working example:
https://jsfiddle.net/6umr3733/1/
Procedure: we set the value of top for the dropdown to -100%. This puts it out of the screen. We give it a transition value for it to be smooth when it goes down.
.dropdown_content {
line-height: 1;
position: absolute;
top:-100%;
background-color: #fff;
z-index:-10;
width: 120%;
left: -20%;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
transition: all 0.5s ease;
}
When we hover over dropdown, your div goes down by 200%, that is, to its original position.
.dropdown:hover .dropdown_content {
top:100%;
}
Hope I helped, good luck.
You can simply use the transform: scaleY(); attribute to squash the submenu to 0 when hidden, and to 1 when visible.
Check JSFiddle
Just remove the Display attributes, and add a transition, and transform: scaleY(0); transform-origin: 0 0; when is normal, and transform: scaleY(1); when hover to .dropdown_content.
I've run in to a bit of a problem. I have a menu list where I custom made some image hover states for list items. This worked perfectly fine until I needed to change the menu items (list item text length, etc). I have to go back and re-make all of the images each time something changes.
Here are some images of what I'm trying to accomplish:
Basically the hover adds a red background and a duplicate of that red region rotated ~2 degrees and is lighter colored. Would it be possible to do this via CSS with :after and transform: rotate()? If not, what would be a nice way of accomplishing this effect for varying word lengths?
Thanks ahead of time!
Tre
This can easily be done with transform as you say. You'll need to have two elements in each button though, one for the text and one for the skewed background:
<div class="menu-button">
<div class="text">Screenings</div>
<div class="hover-bg"></div>
</div>
And style the .hover-bg class something like this:
#menu .menu-button:hover .hover-bg
{
z-index: 1;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: rgba(220, 50, 50, 0.4);
transform: rotate(2deg) scale(1.05, 1);
transform-origin: center right;
}
Here's an example on JSFiddle
Here's an example where I had some fun with transitions. Due to lazyness I only bothered to make it work in Webkit, meaning Chrome and Webkit.
Note that for cross-browser compatibility you'll need the vendor specific property prefixes (-webkit-, -moz-, etc)
this can be done in pure CSS (not even 3).
On hover have a tilted background image, position it a few pixel to the left and top and add background color.
Because of the background color, you will see only a part of the image:
<div class="text">Screenings</div>
.text {
color: #000;
margin-left: 5px;/*to make room for the hover image */
padding: 4px;
}
.text:hover {
background: #900 url(tiltedimage.png) no-repeat -5px -5px;
color: #fff;
}
This will point you to the solution.
I wanted to know what code is used to make a background like this http://www.wareztuga.ws/
What if i want to make a to put a header like that? What code should i use?
I appreciate you help
Not sure what you mean by "different layers".
Do you mean how the flags change from dim to bright? They are just using css3 opacity filter
Something like this:
.class{ filter:alpha(opacity=100); -moz-opacity:1.0; -khtml-opacity:1.0; opacity:1.0; }
.class:hover{ filter:alpha(opacity=70); -moz-opacity:0.7; -khtml-opacity:0.7; opacity:0.7;
If you want to have an image change when you hover over it, you can use the css background-postion filter.
Let's say you have an image that is 20px Wide and 20px High. In photoshop, double the canvas height, and put second image above it. Then in css do something like:
.class{ height:20px; width:20px; background:url('your/image.png'); background-position:0px 0px; }
.class:hover{ background-position:0px -20px; } //or 20px depending on what way you want to move your background image.
Still now sure if that answers your questions.
Otherwise, the "layers" are just divs with background images set. And then children divs with different images set.