I am trying to rotate this div, fix it and float it to the RIGHT like this [jsbin.com/ujebik/1][1] but it don't completely float to the RIGHT
HTML:
<div class="logo">
ROTATE THIS TEXT
</div>
CSS:
.logo {
position: fixed;
top: 20px;
right: 0;
z-index: 100;
width: 250px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transform: rotate(-90deg);
font-size:20px;
background-color:green
}
UPDATE:
want this:
but Have this:
Try to add transform-origin: 100% 100%; to make the div rotate around its lower right corner instead of its center (http://jsbin.com/iniweq/2/)
I am guessing what you are trying to do is have the element on the left? If this is the case then you need to change your CSS to
.logo {
position: fixed;
top: 20px;
left: 0;
z-index: 100;
width: 250px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transform: rotate(-90deg);
font-size:20px;
background-color:green
}
Here is a fiddle: http://jsfiddle.net/Er3yL/
Or if what you are trying to say is that you want to 'float' it to the extreme RIGHT, then I am guessing that the parent element for .logo is not stretched to 100% of the window. Either you can correct that or if you want to keep it that way then you can add a negative value to right, like this
.logo {
position: fixed;
top: 20px;
right: -20px;
z-index: 100;
width: 250px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
transform: rotate(-90deg);
font-size:20px;
background-color:green
}
Related
I am trying to horizontally center align a inline-block element that also has a fixed position. This is because this element is also being animation via transform translation. Current attempt looks like this:
.cd-nav-trigger {
position: fixed;
display: inline-block;
}
.cd-nav-trigger {
bottom: 7%;
left: 48.25%;
top: auto;
right: auto;
width: 44px;
height: 44px;
z-index: 5;
/* image replacement */
overflow: hidden;
text-indent: 100%;
white-space: nowrap;
}
.cd-overlay-nav, .cd-overlay-content {
/* containers of the 2 main rounded backgrounds - these containers are used to position the rounded bgs behind the menu icon */
position: fixed;
bottom: 7%;
left: 48.25%;
height: 4px;
width: 4px;
-webkit-transform: translateX(20px) translateY(-20px);
-moz-transform: translateX(20px) translateY(-20px);
-ms-transform: translateX(20px) translateY(-20px);
-o-transform: translateX(20px) translateY(-20px);
transform: translateX(20px) translateY(-20px);
}
HTML implementation is this:
</div> <!-- cd-overlay-content -->
Menu<span class="cd-icon"></span>
</div>
The left property is not allowing me to correctly align the element, even when set to 50%. Any help would be appreciated.
Try to add a negative margin-left (half of the width)
.cd-nav-trigger {
position: fixed;
bottom: 7%;
left: 50%;
width: 44px;
height: 44px;
margin-left: -22px;
}
Menu<span class="cd-icon"></span>
Is it possible to have a div with a background image which has a skewed bottom AND round corners?
Most examples use only a background color which doesn't have the duplicate image problem that a background image has.
CSS clipping path
The clipping path option works however, it has no support on IE 11.
Closest solution so far
The HTML:
<div class="container">
<div id="parallelogram">
<div class="image"></div>
</div>
</div>
The CSS:
.container {
overflow: hidden;
padding-bottom: 40px;
}
#parallelogram {
width: 300px;
height: 150px;
margin: -41px 0 0 0;
-webkit-transform: skewY(-11deg);
-moz-transform: skewY(-11deg);
-o-transform: skewY(-11deg);
background: red;
overflow: hidden;
position: relative;
border-radius: 40px;
}
.image {
background: url(http://baconmockup.com/340/500);
position: absolute;
top: -30px;
left: -30px;
right: -30px;
bottom: -30px;
-webkit-transform: skewY(11deg);
-moz-transform: skewY(11deg);
-o-transform: skewY(11deg);
}
https://jsfiddle.net/Spindle/81e30bmx/
But the problem with this is that the round corners aren't visible anymore as well...
Adding border-radius to parent div could work, as it will work as border-radius for four corner and then individually using border-top-right-radius, border-top-left-radius,border-bottom-right-radius,border-bottom-left-radius you can change and align accordingly as below and thus it skews at bottom-left along-with border-radius at 4 sides,
.container {
overflow: hidden;
padding-bottom: 40px;
border-top-right-radius:16px;
border-bottom-right-radius:14px;
border-top-left-radius:40px;
margin-top:40px;
display:inline-block;
}
#parallelogram {
width: 300px;
height: 150px;
margin: -41px 0 0 0;
-webkit-transform: skewY(-11deg);
-moz-transform: skewY(-11deg);
-o-transform: skewY(-11deg);
background: red;
overflow: hidden;
position: relative;
border-radius: 40px;
}
.image {
background: url(http://baconmockup.com/340/500);
position: absolute;
top: -30px;
left: -30px;
right: -30px;
bottom: -30px;
-webkit-transform: skewY(11deg);
-moz-transform: skewY(11deg);
-o-transform: skewY(11deg);
}
<div class="container">
<div id="parallelogram">
<div class="image"></div>
</div>
</div>
It is possible and does seems to work on your example.
If you are talking about the top left and right corners getting chopped off, then what you need to do is add a margin to the top so:
#parallelogram { margin: -41px 0 0 0; }
Would become:
#parallelogram { margin: 23px 0 0 0; }
This will adds the hole shape in.
I have this side-pane. It's height is 80%. In this side-pane I have a text. I want this to always be in the middle.
Main div:
.simulation {
height: 80%;
width: 500px;
border: 1px solid #ccc;
box-shadow: 8px 8px 7px #A5A5A5;
background: #FFF;
position: absolute;
top: 10px;
z-index: 100;
left: -450px;
transition: 500ms ease all;
}
Sub div:
.simulation .simulation-content .simulation-bar .heading {
position: relative;
margin-top: 340px; /* How do I get this in the middle?? */
-webkit-transform: rotate(-90deg);
}
I can't get the margin-top right when i express it in %.
Plunkr: http://plnkr.co/edit/Z8xZNYLNvShQDVPZMZgk?p=preview
You could align the child element vertically at the middle of the parent by positioning the child absolutely and a combination of top: 50% and transform: translateY(-50%).
In this particular instance — Example:
.simulation .simulation-content .simulation-bar .heading {
position: absolute;
top: 50%;
left: 0;
-webkit-transform: translate(-30%, -50%) rotate(-90deg);
-moz-transform: translate(-30%, -50%) rotate(-90deg);
-ms-transform: translate(-30%, -50%) rotate(-90deg);
-o-transform: translate(-30%, -50%) rotate(-90deg);
transform: translate(-30%, -50%) rotate(-90deg);
}
An explanation can be found here:
How to center a "position: absolute" element
You can use also flexboxes to achieve it. just add:
display: flex;
flex-flow: column nowrap;
justify-content: center;
to your "main-content"
How do you vertically rotate text on IE8+
The elements I want to vertically rotate are positioned absolutely and require to be in the same place.
<div id="parent">
<div id="child_1">
</div>
<div id="child_2">
</div>
</div>
CSS:
#parent {
position: absolute;
width: 300px;
height: 300px;
}
#child_1 {
postion: absolute;
top: 250px;
left: 50px;
width: 100px;
height: 10px;
}
#child_2 {
postion: absolute;
top: 200px;
left: 10px;
width: 100px;
height: 10px;
}
There is a hack for IE8 using filter however this requires positioning of element for IE separately but I can live with this.
IE8:
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
IE9+:
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
I am working on a website where I need to use different trapezoid shape of images. Here I am giving you that image in link:
Thanks Riccardo, Appreciate your effort.
Following are the 2 points I still need to sort it out.
This is the image that I got after implement your code.
Shape of the site will be skewed but not the image. The current shape is perfect but all images are also got skewed along with the shape which I don't want. I want all the images not to be shown as skewed as it is showing right now. So need guidance on that particular issue.
And the 2nd most important thing is about the total structure of the site. My site will be in 100% but in Container, you have given fixed height and width but I want the height and the width will be 100%.
I have tried by putting 100% width instead of current pixels but it all messed up. Here I am posting my given css. The left part of the shape is fixed, its not increasing while I am giving the widhth 30%. And the right side shape is moving far right and in between middle and right shape the container backgroup is shown which is in orange color as per the css code. And eventually I messed up all things, Here is thislink of that:
One more thing I would like to add is that Can it be possible to put 100% height on that container. Because whenever I tried to put height 100%, the whole structure get vanished. So any solution in that particular height point?
The both image issue and width height 100% issue are important for the website to function. So need your guidance on this.
HTML STRUCTURE FOR REFERENCE:
<div id="container">
<span id="left">
<img src=""/>
</span>
<span id="middle">
<img src=""/>
</span>
<span id="right"></span>
</div>
I made this example for you with pure css.
Now let explain how I made it.
I take a container, set the dimension of that and the relative position.
#container{
width: 600px;
background-color: orange;
height: 300px;
overflow: hidden;
position: relative;
}
If you set the overflow: hidden all the element inside the container will be truncated and they can't expand outside of the parent.
After that I put 3 span in the container, they are inline element so I can't set their width or height. To do that I set their display: property to inline-block. Now I can give to the span a dimension.
The span are in a absolute position because I want the spans to be able to overlap.
For that after the absolute position use z-index.
The 3 span ids.
#left {
position: absolute;
left: -100px;
display: inline-block;
width: 300px;
background-color: red;
height: 300px;
transform: skew(-20deg, 0deg);
-ms-transform: skew(-20deg, 0deg); /* IE 9 */
-webkit-transform: skew(-20deg, 0deg); /* Safari and Chrome */
z-index: 1;
overflow: hidden;
}
#left img {
-webkit-transform: skew(20deg,0deg);
}
#middle {
position: absolute;
left: 200px;
display: inline-block;
width: 200px;
background-color: green;
height: 300px;
transform: skew(-20deg, 0deg);
-ms-transform: skew(-20deg, 0deg); /* IE 9 */
-webkit-transform: skew(-20deg, 0deg); /* Safari and Chrome */
z-index: 3;
border-right: 10px solid white;
border-left: 10px solid white;
overflow: hidden;
}
#middle img {
-webkit-transform: skew(20deg, 0deg);
margin-left: -50px;
}
#right {
position:absolute;
right:-100px;
display:inline-block;
width:400px;
background-color:gray;
height:300px;
transform:skew(-20deg,0deg);
-ms-transform:skew(-20deg,0deg); /* IE 9 */
-webkit-transform:skew(-20deg,0deg); /* Safari and Chrome */
z-index:2;
overflow:hidden;
}
As you can see there are the skew transformation for the shapes, and also the overflow: hidden because I don't want the img inside the span go outside the parent area.
When I put an img inside the skewed span, it take also the skew of the shape. So apply the
#nameofskewedcontainer img {
-webkit-transform: skew(20deg, 0deg);
}
where the skew property are exactly the opposite that is applied to the span. With that I keep the img with the standard shape without skew. (try to remove that in jsfiddle demo and see)
So I hope I was clear. For everything leave a comment!
SECOND UPDATED SOLUTION:
WIDTH 100%
CSS->
#container {
width: 100%;
height: 300px;
overflow: hidden;
position: relative;
}
#left {
position: absolute;
left: -100px;
display: inline-block;
width: 50%;
height: 300px;
transform: skew(-20deg, 0deg);
-ms-transform: skew(-20deg, 0deg); /* IE 9 */
-webkit-transform: skew(-20deg, 0deg); /* Safari and Chrome */
z-index: 1;
overflow: hidden;
}
#left img {
transform: skew(20deg, 0deg);
-moz-transform: skew(20deg, 0deg);
-webkit-transform: skew(20deg, 0deg);
}
#middle {
position:absolute;
left: 30%;
display: inline-block;
width: 40%;
height: 300px;
transform: skew(-20deg, 0deg);
-ms-transform: skew(-20deg, 0deg); /* IE 9 */
-webkit-transform: skew(-20deg, 0deg); /* Safari and Chrome */
z-index: 3;
border-right: 10px solid white;
border-left: 10px solid white;
overflow: hidden;
}
#middle img {
transform: skew(20deg, 0deg);
-moz-transform: skew(20deg, 0deg);
-webkit-transform: skew(20deg, 0deg);
margin-left: -50px;
}
#right {
position: absolute;
right: -100px;
display: inline-block;
width: 50%;
background-color: gray;
height: 300px;
transform: skew(-20deg, 0deg);
-ms-transform: skew(-20deg, 0deg); /* IE 9 */
-webkit-transform: skew(-20deg, 0deg); /* Safari and Chrome */
z-index: 2;
}
Anyway roy, remember that in stackoverflow you can ask of something, but also you have to practice with the answers that are given to you. This is the only way you can really learn something.