CSS Rotate inside rotated element not working - css

I'm trying to rotate an parent div with some child div's, and than rotate the spans inside the child div's back so that the text is still readable...
Here's an JSFiddle
The HTML:
<div id="bt_container">
<div class="row_container">
<div><span>col1.1</span>
</div>
<div><span>col1.2</span>
</div>
<div><span>col1.3</span>
</div>
<div><span>col1.4</span>
</div>
</div>
<div class="row_container">
<div><span>col2.1</span>
</div>
<div><span>col2.2</span>
</div>
<div><span>col2.3</span>
</div>
<div><span>col2.4</span>
</div>
</div>
</div>
And the CSS:
#bt_container {
width: 1000px;
height:600px;
border: 1px solid #333;
}
.row_container {
margin: 10px;
border: 1px solid red;
}
.row_container div {
width:70px;
height: 70px;
border: 1px solid blue;
background: url('http://i.imgur.com/wI9t0bj.png');
background-size: cover;
}
.row_container div {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.row_container div span {
color: white;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
}
But the span isn't rotating back ( it's not rotating on it's own ). So does anybody knows what i do wrong? / What do i have to do to make the text readable again?

Put a display: block; on your span in order to rotate it.

Add display:inline-block or display:block to the span. Or just use block elements instead of span.

working fiddle
edit display and padding (to show entire span text)
.row_container div span {
color: white;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
-ms-transform: rotate(90deg);
transform: rotate(90deg);
display:inline-block;
padding-left:20px;
}

Related

Occupy height of a div when content is rotated

I tried rotating the content of my fixed div and it rotates as expected but the problem is it doesn't occupy the height of the div.
Sample fiddle here.
HTML:
<div class="outer-left">
<h2 class="paginator">Page 1 0f 10</h2>
</div>
CSS:
.outer-left {
background: #EFB041;
height: 100%;
display: block;
width: 4%;
position: fixed;
left: 18%;
}
.paginator {
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
color: #fff;
}
Note: I can make it by applying width = auto on the div but how can I
achieve it using a fixed width?
Now I can achieve it adding
margin-top: 600px;
white-space:nowrap;
inside the paginator class. but is there a way cleaner on how to get this done?
jsfiddle
Maybe this jsfiddle works for you.
HTML:
<div class="outer-left">
<h2 class="paginator">Page 1 of 10</h2>
</div>
>
CSS:
.outer-left {
position: relative;
background: #EFB041;
overflow: hidden;
width: 5%;
left: 18%;
height: 200px;
float: left;
}
.paginator {
position: absolute;
top: 30%;
left: -2.0em;
width: auto;
margin: 0;
padding:0;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
color: #fff;
}

Make a trapezoid with css3 border radius

I want to make a trapezoid with border radius like this picture. Is it possible?
I tried this code but it does not work
background: #BE1E2D;
width: 130px;
height: 75px;
-webkit-transform: skew(20deg);
-moz-transform: skew(20deg);
-o-transform: skew(20deg);
transform: skew(20deg);
Visit this website to look at how a lot of shapes are done.
For this shape though (as it is on the website), you need this:
#parallelogram {
width: 150px;
height: 100px;
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
-o-transform: skew(-20deg);
background: red;
}
Try this. Doesn't use border-radius though.
.trapezoid{
width:100px;
height:100px;
border:1px solid #000;
background:yellow;
transform: skew(-20deg);
-o-transform: skew(-20deg);
-moz-transform: skew(-20deg);
-webkit-transform: skew(-20deg);
}
I don't see how you could do this with border-radius (or why you would want to)
You can do it with a simple skew:
#shape {
width: 150px;
height: 50px;
-webkit-transform: skew(-25deg);
-moz-transform: skew(-25deg);
-o-transform: skew(-25deg);
background: darkred;
}
DEMO

Rotate Element Within H2

Im trying to rotate a <span> within an <h2> 90 degrees.
right now if I just set it to rotate nothing happens - but if I add a display:block to the span then it rotates. My problem is it pushes the rest of the h2 on to the next line.
Is there any way to have the h2 display on one line with the span rotated in middle of it?
here's how it should look
HTML:
<h2>Join <span class="flip-text">With</span><span class="flip-text">Your</span> Family</h2>
CSS:
span.flip-text{font-size:10px; -webkit-transform: rotate(-90deg); -moz-transform: rotate(-90deg); -ms-transform: rotate(-90deg); -o-transform: rotate(-90deg); filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); -ms-filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);}
Just like Christopher was suggesting, display: inline-block is the way to go:
http://jsfiddle.net/X85b6/
<h2>Join<span>with<br />your</span>Family</h2>
h2 {
font-size: 60px;
text-transform: uppercase;
}
h2 span {
font-size: 15px;
line-height: 16px;
display: inline-block;
position: relative;
bottom: 5px;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
-ms-filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}

CSS3 Transform Scale and Container with Overflow

I am trying to create a zoom-in functionality for a container with CSS3 Transform (scale) and all seems to work nicely, but when the image is scaled, the overflow only covers a part of the image, leaving the top left part out of the overflow.
Code is as follows:
HTML:
<div class="outer">
<img id="profile" src="http://flickholdr.com/300/200/" />
</div>
<button class="zoom orig">Original</button>
<button class="zoom x2">x2</button>
<button class="zoom x4">x4</button>
CSS:
.outer { width: 500px; height: 500px; overflow: auto; text-align: center; background: #eee; }
.outer:before { content: ''; display: inline-block; vertical-align: middle; height: 100%; }
.outer img { vertical-align: middle; }
.scale_x2 { -webkit-transform: scale(2); -moz-transform: scale(2); -ms-transform: scale(2); -o-transform: scale(2); transform: scale(2); }
.scale_x4 { -webkit-transform: scale(4); -moz-transform: scale(4); -ms-transform: scale(4); -o-transform: scale(4); transform: scale(4); }
JS:
$(function() {
$('.zoom').on("click", function() {
if ($(this).hasClass('orig')) {
$("#profile").removeClass();
} else if ($(this).hasClass('x2')) {
$("#profile").removeClass().addClass('scale_x2');
} else if ($(this).hasClass('x4')) {
$("#profile").removeClass().addClass('scale_x4');
}
});
});
Check the fiddle here: http://jsfiddle.net/sbaydakov/RhmxV/2/
Any thoughts on how to make this work, so that the whole image is viewable?
Thanks.
The image is scaled from center radially outwards, thus causing the top-left image pixels to disappear. Check this working fiddle http://jsfiddle.net/RhmxV/37/
.scale_x2 {
margin-left: 150px;
margin-top: -193px;
-webkit-transform: scale(2);
-moz-transform: scale(2);
-ms-transform: scale(2);
-o-transform: scale(2);
transform: scale(2);
}
.scale_x4 {
margin-left: 450px;
margin-top: 15px;
-webkit-transform: scale(4);
-moz-transform: scale(4);
-ms-transform: scale(4);
-o-transform: scale(4);
transform: scale(4);
}
If you want to keep the top left corner where it is, use transform-origin:
transform: scale(2);
transform-origin: top left;

Drawing a 12 Point Burst ❋ using CSS

In this page following CSS to draw 12 point burst, how can I put some text inside it (in current form it does not show text inside text, I test z-index without success)?
How can I draw a 12 burst border in it most clean manner?
#burst-12 {
background: red;
width: 80px;
height: 80px;
position: relative;
text-align: center;
}
#burst-12:before, #burst-12:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 80px;
width: 80px;
background: red;
}
#burst-12:before {
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
}
#burst-12:after {
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
-o-transform: rotate(60deg);
}
All you need is to nest another element inside the burst container:
<div id="burst-12"><span>I am the text</span></div>
Then you can style it the way you want:
#burst-12 span {
display:block;
position:absolute;
z-index:2;
}
You'll find a very basic example here.

Resources