0

I want to have my nav rotated 90 degrees and stuck into the top left corner of the viewport, like shown in the sketch I made bellow:

enter image description here

Code:

<div style="width:100vh; height:100px; display:flex; align-items:center; justify-content:space-around; background-color:#CCC; position:fixed; top:0px; left:0px; ">
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
        </div>
Joseph
  • 5,644
  • 3
  • 18
  • 44
gabogabans
  • 3,035
  • 5
  • 33
  • 81
  • 1
    Does this answer your question? [How can I rotate an HTML
    90 degrees?](https://stackoverflow.com/questions/14233341/how-can-i-rotate-an-html-div-90-degrees)
    – kmoser Aug 16 '20 at 18:19
  • Out of principle, I will only provide an answer if one of the following conditions is true: a) you display minimal research effort or b) you remove inline styling. – tao Aug 16 '20 at 18:19
  • There's nothing wrong with inline styling if it helps create a [MRE](https://stackoverflow.com/help/minimal-reproducible-example). – kmoser Aug 16 '20 at 18:22
  • @kmoser, I never said it's wrong (although it is, since we opened the subject - try writing responsve CSS inline, for starters). I just said I won't answer unless one of the conditions is true. It's their choice if they want an answer from me or not. – tao Aug 16 '20 at 18:28

4 Answers4

3

You need:

transform: rotate(-90deg) translate(-100%, 0);
transform-origin: left top;

As shown here: https://stackoverflow.com/a/14233398/378779

kmoser
  • 8,780
  • 3
  • 24
  • 40
0

This should work

<div style="background-color:white; 
   height: 100px;
  width: 100%;
  display:flex; 
  align-items:center; 
  justify-content:space-around; 
  transform: rotate(-90deg) translate(-100%, 0);
  border: 1px solid red;
  transform-origin: left top;">
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
            <span style="font-size:20px; color:red;">LINK</span>
        </div>
Anup
  • 589
  • 4
  • 8
0

span {
 writing-mode:sideways-lr;
 display:block;
 padding:calc(100px / 2 - 8px);
 font-size:20px;
 color:red;
}
body{
 background-color:blue;    
}
<div style="width:108px; height:100%;background-color:#fff;display:block;margin:-8px;outline-offset:-6px;outline: 1px solid red;">
            <span >LINK</span>
            <span >LINK</span>
            <span >LINK</span>
            <span >LINK</span>
            <span >LINK</span>
        </div>
Riyas Ac
  • 1,553
  • 1
  • 9
  • 23
0

You can use the CSS transform property to rotate the nav bar 90°. The code below also takes out the inline styles.

nav {
  width: 100vh;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background-color: #CCC;
  position: fixed;
  top: 0px;
  left: 0px;
  
  /* rotate 90° */
  transform: rotate(90deg);
}

.link {
  font-size: 20px;
  color: red;
}
<nav>
  <span class="link">LINK</span>
  <span class="link">LINK</span>
  <span class="link">LINK</span>
  <span class="link">LINK</span>
  <span class="link">LINK</span>
</nav>