I've searched on here and could not find an answer so I apologise if this has been asked before.
Anyway, im creating a website, and one of the effects im using is a slanting div effect.
But when i create it using the transform, rotate and skew for some reason it makes the website scroll from left to right.
Ive tried putting the overflow to hidden on the parent div but it then hides the slanting effect.
Here is my code...
Html:
<div class="container">
<div class="slant"></div>
<!-- rest of the code goes here -->
</div>
Css:
.container{width:100%;position:relative;}
.slant{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
top: -45px;
position: absolute;
width: 100%;
background-color: inherit;
left: 0;
height: 120px;
overflow: hidden;
z-index: 200;
-webkit-transform: rotate(-2deg) skew(-2deg) scale(1.1,1);
-mox-transform: rotate(-2deg) skew(-2deg) scale(1.1,1);
-ms-transform: rotate(-2deg) skew(-2deg) scale(1.1,1);
-o-transform: rotate(-2deg) skew(-2deg) scale(1.1,1);
transform: rotate(-2deg) skew(-2deg) scale(1.1,1);
}
Ive heard you can do this with ::before pseudo-elements but to be honest I dont know how and cant seem to find a tutorial to show me.
Any help is welcome and will be appreciated
Thanks
Do you use scale(1.1,1) for some strong reason?
You can remove it, and also remove default margin and padding from body, so that container shrinks to the width of the browser. Then everything works (tested in Chrome, FF, IE11).
Your css will look like this:
body {margin:0px;padding:0px;}
.container{width:100%;position:relative;}
.slant{
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
top: -45px;
position: absolute;
width: 100%;
background-color: inherit;
left: 0;
height: 120px;
overflow: hidden;
z-index: 200;
width:100%;
-webkit-transform: rotate(-2deg) skew(-2deg) ;
-mox-transform: rotate(-2deg) skew(-2deg) ;
-ms-transform: rotate(-2deg) skew(-2deg);
-o-transform: rotate(-2deg) skew(-2deg) ;
transform: rotate(-2deg) skew(-2deg);
background-color: red;
}
Related
I currently have a navigation AND a slide down Social menu in Sass which both are fixed.
Yet when I scroll down nothing happens in Chrome. In Safari it does work.
I googled many times and even when I use
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0);
-webkit-transform: translate3d(0, 0, 0);
it still doesn't work.
Here is the css code for my social menu (it has a ul and a li in it)
.social-menu{
position:fixed;
top: 0;
bottom:0;
width:100%;
height:100vh;
z-index:10000;
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0);
-webkit-transform: translate3d(0, 0, 0);
background-color:rgba(123, 123, 123, 0.86);
.social-list{
width:50%;
margin:0 auto;
.social-list-item{
list-style-type: none;
}
}
}
Here is my JSFiddle, my social menu is nested in my body. Here it works, maybe try it out for yourself in chrome?
Also, I make use of <!DOCTYPE html>
http://jsfiddle.net/777t4twf/7/
If you remove the transform-style: preserve-3d from the body and the -webkit-transform: translateZ(0); from the .container it works. Try it in your Chrome DevTools.
I assume that these transforms are (quite rightly) affecting the position of the nav in the z axis.
body {
margin: 0;
padding: 0;
height: 100%;
min-height: 100%;
/* -webkit-transform-style: preserve-3d; */
/* transform-style: preserve-3d; */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.container {
width: 100%;
background-color: #f1f1f1;
/* -webkit-transform: translateZ(0); */
}
Try giving "transform: inherit" in your container of "social-menu".
I tried this and its working for me, as my container element in chrome was adding "transform: none" in computed css of dev tools.
I want one div in my page whose position will be fixed rotation is 30 degree but when I am doing this its shows like this
I Don't want that empty space in the top while rotation. I want Top same as bottom currently in top its showing some space when i rotate my div.
CSS is
#beta{
position:fixed;
bottom:0;
padding:-30px;
z-index: 1;
width: 15em;
height:3em;
background: #65a9d7;
-ms-transform: rotate(30deg); /* IE 9 */
-webkit-transform: rotate(30deg); /* Chrome, Safari, Opera */
transform: rotate(30deg);
}
You can add transform-orign, which will act as rotating axis.
And if you want this to be at top then add top and remove bottom value and while rotating, the blocks shifts so give left value to the half of its height of appropriate value.
#beta{
position:fixed;
top:0;
z-index: 1;
width: 15em;
height:3em;
left: 1.5em;
background: #65a9d7;
-ms-transform: rotate(30deg); /* IE 9 */
-webkit-transform: rotate(30deg); /* Chrome, Safari, Opera */
transform: rotate(30deg);
transform-origin: left top;
}
And one more thing, padding doesn't work with negative value. :)
Have a nice code day.
Take a look at the transform-origin CSS property if you want to set the point at which the object rotates around. In your specific example, the reason there is so much space above is because you've set bottom: 0, which will force a fixed element to snap to the bottom of its parent.
I'm not sure the exact layout you're looking for, but here is something with less white space at the top:
#beta {
position: fixed;
z-index: 1;
width: 15em;
height: 3em;
background: #65a9d7;
-ms-transform: rotate(30deg);
/* IE 9 */
-webkit-transform: rotate(30deg);
/* Chrome, Safari, Opera */
transform: rotate(30deg);
margin-top: 4em;
}
<div id="beta">
Beta Version
</div>
Edit: The following snippet is a follow-up to a comment from the original poster.
.container {
border: 5px solid #000;
height: 5em;
overflow: hidden;
position: relative;
width: 15em;
}
.beta {
background: #65a9d7;
height: 3em;
line-height: 3em;
margin-top: -1.5em;
position: absolute;
text-align: center;
top: 50%;
width: 15em;
-ms-transform: rotate(30deg);
/* IE 9 */
-webkit-transform: rotate(30deg);
/* Chrome, Safari, Opera */
transform: rotate(30deg);
}
<div class="container">
<div class="beta">
Beta Version
</div>
</div>
Hello ive managed to create a star with css but it is hiding the field that i wat to show on front of the star. I was wondering if anyone coud point me i the right direction to what i should do to fix it. thanks
<div class="views-field views-field-field-freebetamount">
<div class="field-content">
<div id="star12">£200</div>
</div>
</div>
css
.views-field-field-freebetamount {
color:white;
}
#star12 {
background: blue;
width: 40px;
height: 40px;
position: relative;
}
#star12:before, #star12:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 40px;
width: 40px;
background: blue;
}
#star12:before {
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
}
#star12:after {
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
-o-transform: rotate(60deg);
}
the freebetamount field should hopefully appear on top of the star. my limited css skills has lead me to try z-indexs but to no avail.
Anyone?
thanks
you have to define the negative z-index value in :before and :after pseudo element.
#star12 {
background: blue;
width: 40px;
height: 40px;
position: relative;
font-size:1.3em;
}
#star12:before, #star12:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 40px;
width: 40px;
background: blue;
z-index:-1;
}
Check the Demo.
With css u need to set z-index: 100 or something like that to place something on top of the others
You're going to want to take a look at z-index. Whichever element you want to appear on top of another needs to have a higher CSS z-index number.
in css file;
#yourID {
z-index: 99;
}
I am trying to develop a dynamic chevron style progress indicator in a web resource.
Here is a jsfiddle of what I am trying to achieve http://jsfiddle.net/3qYyV/
My problem is that when this is put into a web resource the "transform skew's" do not get applied???
Here is an example web resource...
<html>
<head>
<title></title>
<style type="text/css">
.chevron {
float: left;
padding: 0px 0px 0px 2px;
width: 150px;
}
.chevron_a {
height: 100px;
width: 150px;
-webkit-transform: skew(20deg, 0deg);
-moz-transform: skew(20deg, 0deg);
-ms-transform: skew(20deg, 0deg);
-o-transform: skew(20deg, 0deg);
transform: skew(20deg, 0deg);
float: left;
z-index: -1;
}
.chevron_b {
height: 100px;
width: 150px;
-webkit-transform: skew(-20deg, 0deg);
-moz-transform: skew(-20deg, 0deg);
-ms-transform: skew(-20deg, 0deg);
-o-transform: skew(-20deg, 0deg);
transform: skew(-20deg, 0deg);
float: left;
z-index: -1;
}
.chevron_c {
margin-left: auto;
margin-right: auto;
width: 150px;
text-align: center;
font-family: Tahoma;
}
.chevron_m {
display: table-cell;
vertical-align: middle;
}
.chevron_o{
clear: both;
display: table;
position: absolute;
width: 150px;
height: 100px;
}
</style>
</head>
<body>
<div id="chevron_w">
<div class="chevron">
<div class="chevron_a" style="background: #CCCEEE;"></div>
<div class="chevron_b" style="background: #CCCEEE;"></div>
<div class="chevron_o">
<div class="chevron_m">
<div class="chevron_c">TEST</div>
</div>
</div>
</div>
</div>
</body>
Have you loaded your CSS as a separate web resource and referenced it from within your HTML?
http://msdn.microsoft.com/en-us/library/gg309536.aspx
Everything seems to be OK.
Adding CSS to the html Page in head Section will work fine.
Two more thing: Where are you using the Webrescource ??
If you are using the web-resource on IFRame then make sure the JQuery library is added to
the form.
Copy paste the URL of ur Web-Resource in the Internet Explorer and check in the developer tools. Your CSS, Divs, Jquery are working fine no error are being thrown in the console.
Well, It looks like I have found the answer...
Rollup 11 doesn't support CSS3 (i think). With Rollup 11 installed the following meta tag forces IE9+ into IE8 mode and thus ignores the transform skew style.
<META http-equiv=X-UA-Compatible content=IE=8>
Rollup 16 doesn't have this meta tag and the transform skew works fine in IE9+. I'm guessing this came as part of the cross browser compatability released with rollup 12???
I am performing a CSS transform: rotate on a parent, yet would like to be able to negate this effect on some of the children - is it possible without using the reverse rotation?
Reverse rotation does work, but it affects the position of the element, and it may have a negative performance impact (?). In any case, it doesn't look like a clean solution.
I tried the "transform: none" suggestion from this question prevent children from inheriting transformation css3, yet it simply doesn't work - please see the fiddle here: http://jsfiddle.net/NPC42/XSHmJ/
May be you have to write like this:
.child {
position: absolute;
top: 30px;
left: 50px;
background-color: green;
width: 70px;
height: 50px;
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
transform: rotate(-30deg);
}
Check this for more http://jsfiddle.net/XSHmJ/1/
Updated:
You can use:after & :before psuedo class for this.
check this http://jsfiddle.net/XSHmJ/4/
I believe that you are going to need to fake it using a second child, the specification does not seem to allow for the behavior you would like, and I can understand why the position of a child element has to be affected by a transform to its parent.
This isn't the most elegant of solutions, but I think you're trying to do something that the specification is never going to allow. Take a look at the following fiddle for my solution:
.parent {
position: relative;
width: 200px;
height: 150px;
margin: 70px;
}
.child1 {
background-color: yellow;
width: 200px;
height: 150px;
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-o-transform: rotate(30deg);
-ms-transform: rotate(30deg);
transform: rotate(30deg);
}
.child2 {
position: absolute;
top: 30px;
left: 50px;
background-color: green;
width: 70px;
height: 50px;
}
<div class="parent">
<div class="child1"></div>
<div class="child2"></div>
</div>
If you want to apply transforming effects on a parent without affecting its children, you can simply animate a parent's pseudo-element like this:
.parent {
display: inline-block;
position: relative;
}
.parent::before {
content: "";
background: #fab;
/* positioning / sizing */
position: absolute;
left: 0;
top: 0;
/*
be aware that the parent class have to be "position: relative"
in order to get the width/height's 100% working for the parent's width/height.
*/
width: 100%;
height: 100%;
/* z-index is important to get the pseudo element to the background (behind the content of parent)! */
z-index: -1;
transition: 0.5s ease;
/* transform before hovering */
transform: rotate(30deg) scale(1.5);
}
.parent:hover::before {
/* transform after hovering */
transform: rotate(90deg) scale(1);
}
This actually worked for me. JSFiddle