问题
I'm trying to set up a fixed div to the left of a page, 24px from the left and stretching from top to bottom of the page. Inside this div will be navigation and a title. I'm trying to get the title rotated -90 degrees and centered positioned toward the bottom of the div.
Having a tough time figuring this out. Looked around a lot of places and not seeing a similar example. I've set up a fiddle with the current code: https://jsfiddle.net/xkLc9xuy/2/
HTML:
<div>
<article></article>
<footer></footer>
<header></header>
<nav data-secondary></nav>
<nav data-primary>
<div>Website Title</div>
</nav>
</div>
SCSS:
@mixin -position($position:relative, $top:0, $right:0, $bottom:0, $left:0) {
position: $position;
@if $position !=relative {
top: $top;
right: $right;
bottom: $bottom;
left: $left;
}
}
@mixin -transform($transform) {
-ms-transform: $transform;
-webkit-transform: $transform;
transform: $transform;
}
@mixin -transform-origin($origin) {
-ms-transform-origin: $origin;
-webkit-transform-origin: $origin;
transform-origin: $origin;
}
body{
*:not(script){
margin:0;
padding:0;
@include -position;
}
> div{
@include -position(absolute);
}
}
nav[data-primary]{
box-shadow:0 0 8px rgba(0,0,0,0.5);
width:40px;
@include -position(absolute, 0, auto, 0, 24px);
> div{
white-space:nowrap;
height:40px;
line-height:40px;
background-color:red;
@include -transform(rotate(-90deg));
@include -transform-origin(left bottom);
}
}
回答1:
You may also take a look at writing-mode:
-webkit-writing-mode: vertical-lr;
/* old Win safari */
writing-mode: vertical-rl;/*FF*/
writing-mode: tb-lr;
/* writing-mode:sideways-lr;
or eventually scale(-1,-1) untill sideways-lr is working everywhere */
transform: scale(-1, -1);
https://jsfiddle.net/xkLc9xuy/20/
来源:https://stackoverflow.com/questions/38295450/rotating-text-within-a-fixed-div