在固定分区内旋转文字

时间:2016-07-10 18:57:09

标签: html css css-transforms

我试图在页面左侧设置一个固定div,从左侧开始24px并从页面的顶部到底部延伸。在这个div里面将是导航和标题。我试图让标题旋转-90度,并且居中位于div的底部。

很难搞清楚这一点。看了很多地方,没有看到类似的例子。我已经设置了当前代码的小提琴: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 个答案:

答案 0 :(得分:4)

您还可以查看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/