Let's say I have 2 pics. Pic A in front of pic B. I want B to rotate when I hover A. Here's my HTML code
<div id="nav">
<img class="button" src="images/ornament.png"/>
<img class="circle" src="images/profile.png"/>
</div>
And my CSS
.circle:hover .button
{
transition: 3s;
transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate (360deg);
}
Please someone help me with this. Thanks a lot!
CSS currently can't transverse the DOM, therefore it wouldn't be possible in this case. You would need JavaScript in order to do that.
In pure CSS, you could, however, do the opposite. Changing the order of the markup:
<img class="circle" src="//.." />
<img class="button" src="//.." />
EXAMPLE HERE
Either use the adjacent sibling combinator, +, or the general sibling combinator, ~.
.circle:hover + .button {
transition: 3s;
transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate (360deg);
}
Using the same HTML, you could also change the visual order by floating the element(s) in the opposite direction. (example)
Aside from this, it's worth noting that you were using .circle:hover .button; which will select an element with class button that is a descendant of a element with class .circle this is in the :hover state.
Related
I am still learning web development and decided to test my skills by making the minecraft.net website again. On one of the links on the main page there is a dropdown menu with an arrow pointed down beside the link. On hover the dropdown menu comes down and the arrow points up. Does anyone know how to code this hover effect for the link and arrow. Also the arrow changes direction and the menu comes down wherever you hover over the link or the arrow beside it. Your help would be much appreciated. Thanks in advance.
img:hover {
-webkit-transform: rotate(-180deg);
-moz-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
}
If this arrow element (div, img etc) has a class e.g. "dropdown-arrow", you could do something like this:
.dropdown-arrow {
transform: rotate(0deg)
transition: transform 0.3s ease-in-out
}
.dropdown-arrow:hover {
transform: rotate(180deg)
}
Setting two transforms will ensure that when you are not hovering, it will return to its normal rotation. The transition will make this rotation smoother, not an instant change.
You can make an on hover event happen in CSS using the :hover psuedoselector. As for rotating your arrow, this using CSS' rotate() function will work:
#arrow:hover {
transform: rotate(180deg);
}
<div id="arrow">▼</div>
I want to undo older css transform applied to an element and set new rule.
In css we regularly use !important in such cases to override the higher priority rule, but it looks like !important is not taking effect on a transform property:
.mk-flipbox-front {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
I want to override this to:
.mk-flipbox-front {
-webkit-transform: translateX(100%) rotateY(0deg);
transform: translateX(100%) rotateY(0deg);
}
but when I use !important like this:
transform: translateX(100%) rotateY(0deg) !important;
It breaks and will not work.
Any chance we can use !important on a multiple value transform?
To answer your question
Any chance we can use !important on a multiple value transform?
You can use !important the way you are using like in any other property
If your !important rule is not working is because of CSS specificity and/or CSS inheritance
Don't use !important
Instead be more specific, and use a parent selector (or even a sibling selector) to override it
something like this:
.mk-flipbox-front {
-webkit-transform: translateX(100%);
transform: translateX(100%);
}
.parent .mk-flipbox-front {
-webkit-transform: translateX(100%) rotateY(0deg);
transform: translateX(100%) rotateY(0deg);
}
<div class="parent">
<div class="mk-flipbox-front">test</div>
</div>
I have an absolute positioned link who's text I wish to transform
to either
transform: rotate(315)
or
Get the text to arc on the inside
Here is what I have now: link
I have tried:
SVG path
Libraries like arktext.js
EDIT
It seems that it has nothing to do with it being absolute.
It was just 315 was not a valid value.
If you are going to use transform, you need to specify that you are using degrees.
transform: rotate(315deg);
Updated pen
Put your text inside p tags then transform that.
<a href="#skills" id="top-left-circle" class="panel">
<p>Hello</p>
</a>
a > p {
-ms-transform: rotate(315deg);
-webkit-transform: rotate(315deg);
transform: rotate(315deg);
}
http://codepen.io/anon/pen/RWKWOj
I have been looking over this example and wanting to take it up a notch, I am trying for the number "1" card to start off like this
(-webkit-transform: rotateZ( 160deg );) and rotateZ towards 0 WHILE flipping, I've been playing around with the matrix and skewing and cannot seem to get that effect.
You can give the same transform property multiple (space separated) transform-functions at the same time, something like this in your case;
#card .front {
transition: all 1s;
transform: rotateY(0deg) rotateZ(200deg);
}
#card.flipped .front {
transform: rotateY(180deg) rotateZ(0deg);
}
(The same applies to the backface)
Chrome-only demo: http://jsfiddle.net/4Z4sF/
I have to do a web page with some perspective texts on it's menu and contents. Following is a link to an image of the effect I should achieve. Is it possible? Where to start? I'm clueless and don't even know what's the best to do. I appreciate any help.
http://goo.gl/Wlz5b
Rotating text
If you just need to rotate text elements, that can be done with CSS3, using a 2D-transform rotation.
Supporting IE8 and earlier would require using an IE matrix filter (and some extra work to position the text correctly).
JSFiddle Demo
HTML
<div class="content">
<p class="text text1">This is a short sentence.</p>
<p class="text text2">This is a second sentence.</p>
<p class="text text3">This is a third sentence.</p>
</div>
CSS
.text {
-webkit-transform-origin: 0% 0%;
-moz-transform-origin: 0% 0%;
-ms-transform-origin: 0% 0%;
transform-origin: 0% 0%;
}
.text1 {
-webkit-transform: rotate(-4deg);
-moz-transform: rotate(-4deg);
-ms-transform: rotate(-4deg);
transform: rotate(-4deg);
}
.text3 {
-webkit-transform: rotate(4deg);
-moz-transform: rotate(4deg);
-ms-transform: rotate(4deg);
transform: rotate(4deg);
}
3D rotation
If you need true 3D perspective (such that the text is larger on one end than the other), that will be tougher to manage cross-browser. The mock-up in the question doesn't appear to have 3D perspective.