CSS3 transform an element but not its descendants - css

I have an horizontal menu and I want to rotate 90° left or right some of its tabs.
Problem is that the transform property also rotates descendants.
It looks difficult to put them back in place, is there a solution?
P.S. I want to avoid using images or JS, they are ok as fallbacks.

You could apply the reverse rotation on the descendants.
For example
div.parent{
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
}
div.parent span{
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
}
Example: http://jsfiddle.net/RpcfB/1/
Fyi, you will need to play with padding and/or margin to make it all work.
EDIT
I'm afraid it's more complicated than that.
That's the truth!! Although, I as mentioned, you have to play with the css.
For example, to fix the first one, you need to make these adjustments:
add a class to the first li
#nav_main_gts > li.rotate{ //ADD CLASS HERE
-moz-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=-1);
transform: rotate(-90deg);
}
Then change the second rule to target the next ul not li
Then fiddle with the margin to get it all in place. Remember, because the first li is rotated, down is not left, so a negative margin-left is needed
#nav_main_gts > li.rotate ul{ //CHANGE TO UL HERE
-moz-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
transform: rotate(90deg);
margin-left:-100px; //ADD A MARGIN HERE
}
continue with the others.
Updated example: http://jsfiddle.net/FKCTk/1/

Related

How can you add a class in CSS to animate it on the page?

I am trying to animate two images from the centre, the the opposite sides of each other.
One to the far left, and the other to the far right, with some text in the middle.
see jsFiddle
I have seen on a few websites now an is-visible css attribute (for example, something like this):
.image.is-visible {
left: 0%;
-webkit-transform: translateY(0%);
-moz-transform: translateY(0%);
-ms-transform: translateY(0%);
-o-transform: translateY(0%);
transform: translateY(0%);
}
.image {
background-position: right;
-webkit-transform: translateX(45%);
-moz-transform: translateX(45%);
-ms-transform: translateX(45%);
-o-transform: translateX(45%);
transform: translateX(45%);
I have my transform: translateY(0%); on my jsFiddle, but how do you add a class, for example: is-visible to animate it on the page?
Add Class is probably done by a jQuery
https://api.jquery.com/addclass/
So you just need to define when the class should be added
Maybe while scrolling
Example:
http://codepen.io/LukeD1uk/pen/zvGQZN
Or if the document is loaded
$( document ).ready(function() {
$(".someclass").addClass("is-visible");
});

Small Gap on Safari when using transform: translateX

I am using transform: translateX in order to be able to create a sliding effect.
The code works fine under Chrome.
In safari, in some screen resolutions and sometimes under firefox I get a small gap during the animation.
When the animated layer stops the gap dissapears.
Initially I have a
-moz-transform: translateX(100%);
-ms-transform: translateX(100%);
-o-transform: translateX(100%);
transform: translateX(100%);
And after hover, I have a:
-moz-transform: translateX(0%);
-ms-transform: translateX(0%);
-o-transform: translateX(0%);
transform: translateX(0%);
I have a makeup of my code here:
https://jsfiddle.net/e197mrsb/40/
I would be grateful if someone could help.
use margin 0 on hover class .....

text on bottom left corner of screen

I want to keep the name of my portal on the bottom left corner of the browser window in a vertical direction.
The following is the css styling i am using but the text is coming with a margin to the left and bit of text is also getting clipped.
.rotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
font-size:60px;
position: fixed;
left: 0;
bottom: 0;
}
can someone help in correcting my css class please.
here's the JSFiddle link
thank you.
lakshman.
Try this one :
.rotate {
transform-origin:0% bottom;
-moz-transform-origin:0% bottom;
-webkit-transform-origin:0% bottom;
-o-transform-origin:0% bottom;
-ms-transform-origin:0% bottom;
transform:rotate(-90deg) translateY(100%);
-moz-transform:rotate(-90deg) translateY(100%);
-webkit-transform:rotate(-90deg) translateY(100%);
-o-transform:rotate(-90deg) translateY(100%);
-ms-transform:rotate(-90deg) translateY(100%);
display: block;
writing-mode: tb-rl;
position: fixed;
left:0; bottom:0;
margin: auto;
font-size:60px;
background-color:lightblue;
}
<div class="rotate">
LeftBottom
</div>
If You change font-size, then change height and line-height too. You can add padding too, but then You don't need change height and line-height (only if font-size is changed).
There is fiddle example with changed font-size (height, line-height) and padding (just to see how it's working).
UPDATE : I made changes by removing height and line-height. Here and in fiddle example. It's working better.
look at this updated jsfiddle, when you rotate the text it does so from the middle of the div, so when its -90 degrees and on the bottom of the screen part of the div will rotate beneath the window.
.newRotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
font-size:70px;
position: fixed;
left: -100px;
bottom: 110px;
}
To alleviate this I changed the left and bottom position
You can try this and see if its what you are looking for.
.rotate {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
font-size:60px;
position: fixed;
left: -80px;
bottom: 90px;
}

Text bottom-to-top in a table

Is there a way to rotate the text 90 degrees when inside a table:
Something like:
<tr>
<th class="bottomtop">
<span class="bottomtop">{{ task_definition }}</span>
</th>
</tr>
.bottomtotop {
transform:rotate(270deg);
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
I want the text to look like:
h
e
l
l
o
# with the actual letters rotated 90 degrees counter-clockwise.
I think your main problem is that your span has a class of bottomtop, but your CSS defines bottomtotop. I just added a display:block, and corrected the class name and it worked fine. http://jsfiddle.net/c5FzT/
.bottomtop {
display:block;
transform:rotate(270deg);
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
May be you want something like this
.bottomtotop {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
display:inline-block
}
The most important thing is that span is an inline element. transform doesn't work with that. So you need to use either block elements or use display:inline-block or display:block with span and of-course match the class name with markup. (you mentioned bottomtop in your markup but in your css it is bottomtotop)
Js Fiddle

CSS3 rotation causing problems IE9

I am using the following in IE9:
filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
It works in the way it rotates the text, but oddly it gives the element a black background for no reason?!
The CSS:
.view-see-the-difference-in-your-sector .views-field-title span {
display: block;
-moz-transform: rotate(-90deg);
-webkit-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform:rotate(-90deg);
filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
zoom: 1;
-moz-transform-origin: 0 0;
-webkit-transform-origin: 0 0;
-o-transform-origin: 0 0;
-ms-transform-origin: 0 0;
width: 200px;
}
Also notice I have an origin for all browser rotations apart from the filter one.
What is the correct syntax to use here?
I find this hack that fix the problem for me. You should add filter:none; style to the container with black background. Somehow ie9 does not support filter style used for ie8 so you have to disable it. In your case:
.ie9 .view-see-the-difference-in-your-sector .views-field-title span {
filter:none;
}
You have to detect if your browser is ie9 and add this class to some parent node like the body tag.
We were using : transform: rotate(45deg); not working in Chrome and IE9.
First Try : Tried solution given in CSS rotate property in IE, it was not working in IE9.
i.e:
-moz-transform: rotate(45deg); /* FF3.5/3.6 */
-o-transform: rotate(45deg); /* Opera 10.5 */
-webkit-transform: rotate(45deg); /* Saf3.1+ */
transform: rotate(45deg);
Solution : Final solution i.e:
-moz-transform: rotate(45deg); /* FF3.5/3.6 */
-o-transform: rotate(45deg); /* Opera 10.5 */
-webkit-transform: rotate(45deg); /* Saf3.1+ */
transform: rotate(45deg);
-ms-transform: rotate(45deg);
ms-transform: rotate(45deg); /* This Line did the trick for IE9
Found the solution from following URL : http://bugs.jquery.com/ticket/8346

Resources