I've been looking this CSS3 Pie.
https://codepen.io/anon/pen/gxQarR
HTML
<div class="pie big" data-start="270" data-value="360"></div>
<div class="pie" data-start="0" data-value="90"></div>
<div class="pie" data-start="90" data-value="180">2</div>
<div class="pie" data-start="180" data-value="90">3</div>
<div class="pie" data-start="180" data-value="270">4</div>
CSS
/*
make each pie piece a rectangle twice as high as it is wide.
move the transform origin to the middle of the left side.
Also ensure that overflow is set to hidden.
*/
.pie {
position:absolute;
width:400px;
height:800px;
overflow:hidden;
left:600px;
-moz-transform-origin:left center;
-ms-transform-origin:left center;
-o-transform-origin:left center;
-webkit-transform-origin:left center;
transform-origin:left center;
}
/*
unless the piece represents more than 50% of the whole chart.
then make it a square, and ensure the transform origin is
back in the center.
NOTE: since this is only ever a single piece, you could
move this to a piece specific rule and remove the extra class
*/
.pie.big {
width:800px;
height:800px;
left:50px;
-moz-transform-origin:center center;
-ms-transform-origin:center center;
-o-transform-origin:center center;
-webkit-transform-origin:center center;
transform-origin:center center;
}
/*
this is the actual visible part of the pie.
Give it the same dimensions as the regular piece.
Use border radius make it a half circle.
move transform origin to the middle of the right side.
Push it out to the left of the containing box.
*/
.pie:BEFORE {
content:"";
position:absolute;
width:400px;
height:800px;
left:-400px;
border-radius:400px 0 0 400px;
-moz-transform-origin:right center;
-ms-transform-origin:right center;
-o-transform-origin:right center;
-webkit-transform-origin:right center;
transform-origin:right center;
}
/* if it's part of a big piece, bring it back into the square */
.pie.big:BEFORE {
left:0px;
}
/*
big pieces will also need a second semicircle, pointed in the
opposite direction to hide the first part behind.
*/
.pie.big:AFTER {
content:"";
position:absolute;
width:200px;
height:400px;
left:200px;
border-radius:0 100px 100px 0;
}
/*
add colour to each piece.
*/
.pie:nth-of-type(1):BEFORE,
.pie:nth-of-type(1):AFTER {
background: url(http://takeawayshop.dk/image/frontpage/pizza-1471406_960_720.jpg) no-repeat;
-ms-transform: rotate(360deg); /* IE 9 */
-webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
transform: rotate(360deg);
}
.pie:nth-of-type(2):AFTER,
.pie:nth-of-type(2):BEFORE {
background-color:green;
}
.pie:nth-of-type(3):AFTER,
.pie:nth-of-type(3):BEFORE {
background-color:red;
}
.pie:nth-of-type(4):AFTER,
.pie:nth-of-type(4):BEFORE {
background-color:orange;
}
/*
now rotate each piece based on their cumulative starting
position
*/
.pie[data-start="0"] {
-moz-transform: rotate(0deg); /* Firefox */
-ms-transform: rotate(0deg); /* IE */
-webkit-transform: rotate(0deg); /* Safari and Chrome */
-o-transform: rotate(0deg); /* Opera */
transform:rotate(0deg);
}
.pie[data-start="90"] {
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE */
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-o-transform: rotate(90deg); /* Opera */
transform:rotate(90deg);
}
.pie[data-start="180"] {
-moz-transform: rotate(180deg); /* Firefox */
-ms-transform: rotate(180deg); /* IE */
-webkit-transform: rotate(180deg); /* Safari and Chrome */
-o-transform: rotate(180deg); /* Opera */
transform:rotate(180deg);
}
.pie[data-start="270"] {
-moz-transform: rotate(270deg); /* Firefox */
-ms-transform: rotate(270deg); /* IE */
-webkit-transform: rotate(270deg); /* Safari and Chrome */
-o-transform: rotate(270deg); /* Opera */
transform:rotate(270deg);
}
.pie[data-start="360"] {
-moz-transform: rotate(360deg); /* Firefox */
-ms-transform: rotate(360deg); /* IE */
-webkit-transform: rotate(360deg); /* Safari and Chrome */
-o-transform: rotate(360deg); /* Opera */
transform:rotate(360deg);
}
/*
and rotate the amount of the pie that's showing.
NOTE: add an extra degree to all but the final piece,
to fill in unsightly gaps.
*/
.pie[data-value="90"]:BEFORE {
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE */
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-o-transform: rotate(90deg); /* Opera */
transform:rotate(90deg);
}
.pie[data-value="180"]:BEFORE {
-moz-transform: rotate(180deg); /* Firefox */
-ms-transform: rotate(180deg); /* IE */
-webkit-transform: rotate(180deg); /* Safari and Chrome */
-o-transform: rotate(180deg); /* Opera */
transform:rotate(180deg);
}
.pie[data-value="270"]:BEFORE {
-moz-transform: rotate(270deg); /* Firefox */
-ms-transform: rotate(270deg); /* IE */
-webkit-transform: rotate(270deg); /* Safari and Chrome */
-o-transform: rotate(270deg); /* Opera */
transform:rotate(270deg);
}
.pie[data-value="360"]:BEFORE {
-moz-transform: rotate(360deg); /* Firefox */
-ms-transform: rotate(360deg); /* IE */
-webkit-transform: rotate(360deg); /* Safari and Chrome */
-o-transform: rotate(360deg); /* Opera */
transform:rotate(360deg);
}
/*
NOTE: you could also apply custom classes (i.e. .s0 .v30)
but if the CSS3 attr() function proposal ever gets implemented,
then all the above custom piece rules could be replaced with
the following:
.pie[data-start] {
transform:rotate(attr(data-start,deg,0);
}
.pie[data-value]:BEFORE {
transform:rotate(attr(data-value,deg,0);
}
*/
I am attepmting to create this pie, with pictures in each 90* peice.
Yet I have had no luck rotating the picture, so it looks proper.
I've attepmted to take usage of the transform rotate, yet with no luck.
I thought of rotating the picture in Photoshop, so it'd fit. Are there any other ways to do it?
why don't you try something like this codepen.io
<div class="wrapper">
<div class="box box-1"></div>
<div class="box box-2"></div>
<div class="box box-3"></div>
<div class="box box-4"></div>
</div>
<style>
.wrapper {
width:800px;
}
.box {
float: left;
display:inline-block;
width: 400px;
height:400px;
background-color:#000;
}
.box + .box + .box {
margin-top:-4px;
}
.box-1 {
background: url(http://takeawayshop.dk/image/frontpage/pizza-1471406_960_720.jpg) no-repeat;
border-top-left-radius:100%;
}
.box-2 {
background: url(http://media.rtl.fr/cache/kfnpEy__8SYEunR6sbHTZg/2000v1333-0/online/image/2017/0331/7787896201_le-masque-insecte-d-une-grenouille.jpg) no-repeat;
border-top-right-radius:100%;
}
.box-3 {
background: url(https://cdn.pixabay.com/photo/2016/06/18/17/42/image-1465348_960_720.jpg) no-repeat;
border-bottom-left-radius:100%;
}
.box-4 {
background: url(https://cdn.pixabay.com/photo/2017/04/05/11/56/image-in-the-image-2204798_960_720.jpg) no-repeat;
border-bottom-right-radius:100%;
}
</style>
One option would be that you add a new element inside the pie piece that you can control independently of the overall piece, and put the background image on that inner element.
<div class="pie" data-start="0" data-value="90">
<div class="pie background"></div>
</div>
<div class="pie" data-start="90" data-value="180">2</div>
<div class="pie" data-start="180" data-value="90">3</div>
<div class="pie" data-start="180" data-value="270">4</div>
(Note how I also removed the extra pie piece you had. It was unnecessary for this example.)
Then in your CSS, this:
.pie:nth-of-type(1):BEFORE,
.pie:nth-of-type(1):AFTER {
background: url(http://takeawayshop.dk/image/frontpage/pizza-1471406_960_720.jpg) no-repeat;
-ms-transform: rotate(360deg); /* IE 9 */
-webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
transform: rotate(360deg);
}
Becomes:
.pie.background:BEFORE,
.pie.background:AFTER {
background: url(http://takeawayshop.dk/image/frontpage/pizza-1471406_960_720.jpg) no-repeat;
-ms-transform: rotate(360deg); /* IE 9 */
-webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
transform: rotate(360deg);
}
And you can add:
.pie.background {
left: 0;
}
.pie.background::before {
left: 0;
transform-origin: initial;
border-radius: 0 400px 400px 0;
}
.pie {
position: absolute;
width: 400px;
height: 800px;
overflow: hidden;
left: 600px;
-moz-transform-origin: left center;
-ms-transform-origin: left center;
-o-transform-origin: left center;
-webkit-transform-origin: left center;
transform-origin: left center;
}
.pie.background {
left: 0;
}
.pie.background::before {
left: 0;
transform-origin: initial;
border-radius: 0 400px 400px 0;
}
.pie.background:BEFORE,
.pie.background:AFTER {
background: url(http://takeawayshop.dk/image/frontpage/pizza-1471406_960_720.jpg) no-repeat;
-ms-transform: rotate(360deg); /* IE 9 */
-webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
transform: rotate(360deg);
}
.pie:BEFORE {
content: "";
position: absolute;
width: 400px;
height: 800px;
left: -400px;
border-radius: 400px 0 0 400px;
-moz-transform-origin: right center;
-ms-transform-origin: right center;
-o-transform-origin: right center;
-webkit-transform-origin: right center;
transform-origin: right center;
}
.pie:nth-of-type(2):AFTER,
.pie:nth-of-type(2):BEFORE {
background-color: green;
}
.pie:nth-of-type(3):AFTER,
.pie:nth-of-type(3):BEFORE {
background-color: red;
}
.pie:nth-of-type(4):AFTER,
.pie:nth-of-type(4):BEFORE {
background-color: orange;
}
.pie[data-start="0"] {
-moz-transform: rotate(0deg); /* Firefox */
-ms-transform: rotate(0deg); /* IE */
-webkit-transform: rotate(0deg); /* Safari and Chrome */
-o-transform: rotate(0deg); /* Opera */
transform: rotate(0deg);
}
.pie[data-start="90"] {
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE */
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-o-transform: rotate(90deg); /* Opera */
transform: rotate(90deg);
}
.pie[data-start="180"] {
-moz-transform: rotate(180deg); /* Firefox */
-ms-transform: rotate(180deg); /* IE */
-webkit-transform: rotate(180deg); /* Safari and Chrome */
-o-transform: rotate(180deg); /* Opera */
transform: rotate(180deg);
}
.pie[data-start="270"] {
-moz-transform: rotate(270deg); /* Firefox */
-ms-transform: rotate(270deg); /* IE */
-webkit-transform: rotate(270deg); /* Safari and Chrome */
-o-transform: rotate(270deg); /* Opera */
transform: rotate(270deg);
}
.pie[data-value="90"]:BEFORE {
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE */
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-o-transform: rotate(90deg); /* Opera */
transform: rotate(90deg);
}
.pie[data-value="180"]:BEFORE {
-moz-transform: rotate(180deg); /* Firefox */
-ms-transform: rotate(180deg); /* IE */
-webkit-transform: rotate(180deg); /* Safari and Chrome */
-o-transform: rotate(180deg); /* Opera */
transform: rotate(180deg);
}
.pie[data-value="270"]:BEFORE {
-moz-transform: rotate(270deg); /* Firefox */
-ms-transform: rotate(270deg); /* IE */
-webkit-transform: rotate(270deg); /* Safari and Chrome */
-o-transform: rotate(270deg); /* Opera */
transform: rotate(270deg);
}
<div class="pie" data-start="0" data-value="90">
<div class="pie background"></div>
</div>
<div class="pie" data-start="90" data-value="180">2</div>
<div class="pie" data-start="180" data-value="90">3</div>
<div class="pie" data-start="180" data-value="270">4</div>
hope this helps
/*
make each pie piece a rectangle twice as high as it is wide.
move the transform origin to the middle of the left side.
Also ensure that overflow is set to hidden.
*/
.pie {
position:absolute;
width:400px;
height:800px;
overflow:hidden;
left:600px;
-moz-transform-origin:left center;
-ms-transform-origin:left center;
-o-transform-origin:left center;
-webkit-transform-origin:left center;
transform-origin:left center;
}
/*
unless the piece represents more than 50% of the whole chart.
then make it a square, and ensure the transform origin is
back in the center.
NOTE: since this is only ever a single piece, you could
move this to a piece specific rule and remove the extra class
*/
.pie.big {
width:800px;
height:800px;
left:50px;
-moz-transform-origin:center center;
-ms-transform-origin:center center;
-o-transform-origin:center center;
-webkit-transform-origin:center center;
transform-origin:center center;
}
/*
this is the actual visible part of the pie.
Give it the same dimensions as the regular piece.
Use border radius make it a half circle.
move transform origin to the middle of the right side.
Push it out to the left of the containing box.
*/
.pie:BEFORE {
content:"";
position:absolute;
width:400px;
height:800px;
left:-400px;
border-radius:400px 0 0 400px;
-moz-transform-origin:right center;
-ms-transform-origin:right center;
-o-transform-origin:right center;
-webkit-transform-origin:right center;
transform-origin:right center;
}
/* if it's part of a big piece, bring it back into the square */
.pie.big:BEFORE {
left:0px;
}
/*
big pieces will also need a second semicircle, pointed in the
opposite direction to hide the first part behind.
*/
.pie.big:AFTER {
content:"";
position:absolute;
width:200px;
height:400px;
left:200px;
border-radius:0 100px 100px 0;
}
/*
add colour to each piece.
*/
.pie:nth-of-type(1):BEFORE,
.pie:nth-of-type(1):AFTER {
background: url(http://takeawayshop.dk/image/frontpage/pizza-1471406_960_720.jpg) no-repeat;
-ms-transform: rotate(360deg); /* IE 9 */
-webkit-transform: rotate(360deg); /* Chrome, Safari, Opera */
transform: rotate(360deg);
}
.pie:nth-of-type(2):AFTER,
.pie:nth-of-type(2):BEFORE {
background-color:green;
}
.pie:nth-of-type(3):AFTER,
.pie:nth-of-type(3):BEFORE {
background-color:red;
}
.pie:nth-of-type(4):AFTER,
.pie:nth-of-type(4):BEFORE {
background-color:orange;
}
/*
now rotate each piece based on their cumulative starting
position
*/
.pie[data-start="0"] {
-moz-transform: rotate(0deg); /* Firefox */
-ms-transform: rotate(0deg); /* IE */
-webkit-transform: rotate(0deg); /* Safari and Chrome */
-o-transform: rotate(0deg); /* Opera */
transform:rotate(0deg);
}
.pie[data-start="90"] {
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE */
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-o-transform: rotate(90deg); /* Opera */
transform:rotate(90deg);
}
.pie[data-start="180"] {
-moz-transform: rotate(180deg); /* Firefox */
-ms-transform: rotate(180deg); /* IE */
-webkit-transform: rotate(180deg); /* Safari and Chrome */
-o-transform: rotate(180deg); /* Opera */
transform:rotate(180deg);
}
.pie[data-start="270"] {
-moz-transform: rotate(270deg); /* Firefox */
-ms-transform: rotate(270deg); /* IE */
-webkit-transform: rotate(270deg); /* Safari and Chrome */
-o-transform: rotate(270deg); /* Opera */
transform:rotate(270deg);
}
.pie[data-start="360"] {
-moz-transform: rotate(360deg); /* Firefox */
-ms-transform: rotate(360deg); /* IE */
-webkit-transform: rotate(360deg); /* Safari and Chrome */
-o-transform: rotate(360deg); /* Opera */
transform:rotate(360deg);
}
/*
and rotate the amount of the pie that's showing.
NOTE: add an extra degree to all but the final piece,
to fill in unsightly gaps.
*/
.pie[data-value="90"]:BEFORE {
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE */
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-o-transform: rotate(90deg); /* Opera */
transform:rotate(90deg);
}
.pie[data-value="180"]:BEFORE {
-moz-transform: rotate(180deg); /* Firefox */
-ms-transform: rotate(180deg); /* IE */
-webkit-transform: rotate(180deg); /* Safari and Chrome */
-o-transform: rotate(180deg); /* Opera */
transform:rotate(180deg);
}
.pie[data-value="270"]:BEFORE {
-moz-transform: rotate(270deg); /* Firefox */
-ms-transform: rotate(270deg); /* IE */
-webkit-transform: rotate(270deg); /* Safari and Chrome */
-o-transform: rotate(270deg); /* Opera */
transform:rotate(270deg);
}
.pie[data-value="360"]:BEFORE {
-moz-transform: rotate(360deg); /* Firefox */
-ms-transform: rotate(360deg); /* IE */
-webkit-transform: rotate(360deg); /* Safari and Chrome */
-o-transform: rotate(360deg); /* Opera */
transform:rotate(360deg);
}
/*
NOTE: you could also apply custom classes (i.e. .s0 .v30)
but if the CSS3 attr() function proposal ever gets implemented,
then all the above custom piece rules could be replaced with
the following:
.pie[data-start] {
transform:rotate(attr(data-start,deg,0);
}
.pie[data-value]:BEFORE {
transform:rotate(attr(data-value,deg,0);
}
*/
.pie:nth-of-type(2):BEFORE, .pie:nth-of-type(2):AFTER {
background: url(https://dummyimage.com/600x400/eb0707/fff) no-repeat;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.pie:nth-of-type(3):BEFORE, .pie:nth-of-type(3):AFTER {
background: url(https://dummyimage.com/600x400/e7fa14/fff) no-repeat;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.pie:nth-of-type(4):BEFORE, .pie:nth-of-type(4):AFTER {
background: url(https://dummyimage.com/600x400/9a05eb/fff) no-repeat;
-ms-transform: rotate(90deg);
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.pie[data-start="270"] {
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-webkit-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
<div class="pie" data-start="0" data-value="90"></div>
<div class="pie" data-start="90" data-value="180">2</div>
<div class="pie" data-start="180" data-value="90">3</div>
<div class="pie" data-start="270" data-value="270">4</div>
Related
I have an image that I want to make the height 75% of what it normally would be. I am using a responsive layout, so this cannot be done using fixed pixel heights, etc. This will not work as a background image, so I am wondering if there is a similar effect to using background-size: 100% 75%; but that will work on an img tag? I would like to achieve this using just CSS.
Edit:
Example: https://jsfiddle.net/x9n0t4bu/
HTML:
<div id="disp">
<a href="google.com"><img src="http://wowslider.com/sliders/
demo-10/data/images/dock.jpg"></a>
</div>
CSS:
#disp{
margin-top:-17.9px;
width: 100%;
}
#disp img{
width:100%;
}
You can use transform: scale, this should make the image 75% of its original size.
-webkit-transform: scale(0.75); /* Saf3.1+, Chrome */
-moz-transform: scale(0.75); /* FF3.5+ */
-ms-transform: scale(0.75); /* IE9 */
-o-transform: scale(0.75); /* Opera 10.5+ */
transform: scale(0.75);
#disp{
margin-top:-17.9px;
width: 100%;
}
#disp img{
-webkit-transform: scale(1, 0.75); /* Saf3.1+, Chrome */
-moz-transform: scale(1, 0.75); /* FF3.5+ */
-ms-transform: scale(1, 0.75); /* IE9 */
-o-transform: scale(1, 0.75); /* Opera 10.5+ */
transform: scale(1,0.75);
width:100%;
}
<div id="disp">
<a href="google.com"><img src="http://wowslider.com/sliders/
demo-10/data/images/dock.jpg"></a>
</div>
What will be the code for such kind of border
try This
Html
<div class="wrapper">
<div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div><div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div>
<div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div><div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div>
</div>
Css
#container_2 {
width: 80px;
height: 80px;
margin:16px;
float:left;
border: 1px solid red;
-webkit-transform: rotate(45deg); /* Safari and Chrome */
-moz-transform: rotate(45deg); /* Firefox */
-ms-transform: rotate(45deg); /* IE 9 */
-o-transform: rotate(45deg); /* Opera */
transform: rotate(45deg);
}
.wrapper
{
padding:20px;
border:1px solid black;
float:left;
}
img
{
-webkit-transform: rotate(-45deg); /* Safari and Chrome */
-moz-transform: rotate(-45deg); /* Firefox */
-ms-transform: rotate(-45deg); /* IE 9 */
-o-transform: rotate(-45deg); /* Opera */
transform: rotate(-45deg);
position: absolute;
top: 21px;
left: 21px;
}
Demo Here
#container_2 {
width: 80px;
height: 80px;
margin:16px;
float:left;
border: 1px solid red;
-webkit-transform: rotate(45deg); /* Safari and Chrome */
-moz-transform: rotate(45deg); /* Firefox */
-ms-transform: rotate(45deg); /* IE 9 */
-o-transform: rotate(45deg); /* Opera */
transform: rotate(45deg);
}
.wrapper
{
padding:20px;
border:1px solid black;
float:left;
}
img
{
-webkit-transform: rotate(-45deg); /* Safari and Chrome */
-moz-transform: rotate(-45deg); /* Firefox */
-ms-transform: rotate(-45deg); /* IE 9 */
-o-transform: rotate(-45deg); /* Opera */
transform: rotate(-45deg);
position: absolute;
top: 21px;
left: 21px;
}
<div class="wrapper">
<div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div><div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div>
<div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div><div id="container_2"><img src="https://cdn1.iconfinder.com/data/icons/iconbeast-lite/30/crown.png"/></div>
</div>
.reddiv {
background: #FF0000;
border-radius: 50%;
display: block;
height: 60px;
width: 60px;
}
.reddiv::after {
content:"\2193"; /* The code for the arrow : see the reference */
display: block;
color: white;
font-weight: bolder;
font-size: 40px; /* Adjust for your needs */
text-align: center;
}
This is the plnk url
http://plnkr.co/edit/lSh4cGgT4lRorQd4Lg6s?p=preview
I am unable to understand on how to proceed further
Use it in a single animation and use transform rotate.
#keyframes slidedown {
0% {
margin-top: 0;
}
30%{
margin-top: 300px;
-ms-transform: rotate(0deg); /* IE 9 */
-webkit-transform: rotate(0deg); /* Chrome, Safari, Opera */
transform: rotate(0deg);
}
60% {
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
margin-top: 300px;
margin-left: 0;
}
100%{
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
margin-top: 300px;
margin-left: 300px;
}
}
Here is a the forked plnk
I have the following code which displays text vertically.FIDDLE
<div id="btn-toggle-menu">
M
e
n
u
</div>
CSS:
#btn-toggle-menu {
top:0;
left:0;
width:20px;
cursor:pointer;
font-weight:bold;
background-color:#ccc;
text-align:center;
white-space: pre;
}
O/P:
I want the text to be displayed like the one which points to Required menu text. Can someone give me a demo fiddle?
check this link
css
#btn-toggle-menu {
top:0;
left:0;
width:20px;
height:500px;
cursor:pointer;
font-weight:bold;
background-color:#ccc;
text-align:center;
white-space: pre;
vertical-align:middle;
}
#inner-div
{
-webkit-transform:rotate(-90deg);
-moz-transform:rotate(-90deg);
-o-transform: rotate(-90deg);
white-space:nowrap;
margin-top:150px;
}
Add a span with this class (or change css selector), this should do it
.textWrapper{
background: #FFF;
display: inline-block; /* inline doenst work, block seems to make it switch CC<->CCW */
-moz-transform:rotate(90deg); /* FireFox*/
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-o-transform:rotate(90deg); /* Opera */
-ms-transform:rotate(90deg); /* IE9 */
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)"; /* IE8 */
transform: rotate(90deg);/* The way it should work: */
}
This will probably turn the wrong way, just change it to -90, or 270 degrees.
Bear in mind that IE8 doesnt do very will in odd numbers (like 67), stick to 45degree steps to avoid that
I did not add code for IE7 or older, those should be burned without mercy.
Very simple fiddle: http://jsfiddle.net/DqTe6/1/ . This doesnt improve the font. You might need to go with an image.
Normally I prefer text over image, but the text 'menu' has no SEO value whatsoever
<div id="btn-toggle-menu">
<p class="text">Menu</p>
</div>
.text
{
-moz-transform: rotate(-90.0deg); /* FF3.5+ */
-o-transform: rotate(-90.0deg); /* Opera 10.5 */
-webkit-transform: rotate(-90.0deg); /* Saf3.1+, Chrome */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);
/* IE6,IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)";
}
Fiddle:
http://jsfiddle.net/VmH5g/
Try this,
HTML
<div class="bg">
<div id="btn-toggle-menu">Menu</div>
</div>
CSS
#btn-toggle-menu {
background-color: #FFFFFF;
cursor: pointer;
font-weight: bold;
height: 20px;
left: -10px;
position: absolute;
text-align: center;
top: 40%;
width: 40px;
/* white-space: pre;*/ /* Safari */
-webkit-transform: rotate(-90deg);
/* Firefox */
-moz-transform: rotate(-90deg);
/* IE */
-ms-transform: rotate(-90deg);
/* Opera */
-o-transform: rotate(-90deg);
/* Internet Explorer */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
.bg{background-color:#ccc;height:100px;width:20px;position:relative}
Fiddle http://jsfiddle.net/FWzAS/35/
Refer http://css-tricks.com/snippets/css/text-rotation/
Do you mean like this?
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
-ms-transform-origin: 50% 50%;
-o-transform-origin: 50% 50%;
transform-origin: 50% 50%;
Click here for demo
Live Demo
use belo CSS in your code:
-webkit-transform: rotate(-90deg);
-ff-transform: rotate(-90deg);
transform: rotate(-90deg);
Here you go..
Slightly modified version of #Martijn's answer.
http://jsfiddle.net/SmtCS/
CSS
.textWrapper{
background: #FFF;
/* FireFox*/
-moz-transform:rotate(270deg);
/* Safari and Chrome */
-webkit-transform:rotate(270deg);
/* Opera */
-o-transform:rotate(270deg);
/* IE9 */
-ms-transform:rotate(270deg);
/* IE8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod='auto expand', M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";
}
HTML
<div id="btn-toggle-menu" class="btn textWrapper">M e n u </div>
Try the JS fiddle
http://jsfiddle.net/jWJMn/
.element {
-moz-transform: rotate(270deg);
-webkit-transform: rotate(270deg) ;
-o-transform: rotate(270deg) ;
-ms-transform: rotate(270deg) ;
transform: rotate(270deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
background-color:yellow;
height:50px;
width:50px;
}
I have a <div> that I want to rotate 90 degrees:
<div id="container_2"></div>
How can I do this?
You need CSS to achieve this, e.g.:
#container_2 {
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
Demo:
#container_2 {
width: 100px;
height: 100px;
border: 1px solid red;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
<div id="container_2"></div>
(There's 45 degrees rotation in the demo, so you can see the effect)
Note: The -o- and -moz- prefixes are no longer relevant and probably not required. IE9 requires -ms- and Safari and the Android browser require -webkit-
Update 2018: Vendor prefixes are not needed anymore. Only transform is sufficient. (thanks #rinogo)
Use following in your CSS
div {
-webkit-transform: rotate(90deg); /* Safari and Chrome */
-moz-transform: rotate(90deg); /* Firefox */
-ms-transform: rotate(90deg); /* IE 9 */
-o-transform: rotate(90deg); /* Opera */
transform: rotate(90deg);
}
Use transform: rotate(90deg):
#container_2 {
border: 1px solid;
padding: .5em;
width: 5em;
height: 5em;
transition: .3s all; /* rotate gradually instead of instantly */
}
#container_2:hover {
-webkit-transform: rotate(90deg); /* to support Safari and Android browser */
-ms-transform: rotate(90deg); /* to support IE 9 */
transform: rotate(90deg);
}
<div id="container_2">This box should be rotated 90° on hover.</div>
Click "Run code snippet", then hover over the box to see the effect of the transform.
Realistically, no other prefixed entries are needed. See Can I use CSS3 Transforms?
Use the css "rotate()" method:
div {
width: 100px;
height: 100px;
background-color: yellow;
border: 1px solid black;
}
div#rotate{
transform: rotate(90deg);
}
<div>
normal div
</div>
<br>
<div id="rotate">
This div is rotated 90 degrees
</div>
you can use css3 property writing-mode
writing-mode: tb-rl
css-tricks
mozilla
We can add the following to a particular tag in CSS:
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
In case of half rotation change 90 to 45.