JavaScript css rotation with absolute position rotation absolute,rotation absolute value,rotation absolute reference frame,rotation

I have a fixed background, and a div with an absolute position in it; I would like to place it at the top: 5px and left: 5px, It's working when I have no rotation of the text, but I want to get my text verticaly, so I make a rotation 90°. I would like to stick it from left: 5px and top 5px but when I apply the rotation, the text is cut above the page, and even the left part is misplaced ..

Here is some css code (I'm using glamor but it should work the same as normal css)

const background = css({
  background: 'url(/static/profile.jpg) no-repeat left top fixed',
  backgroundSize: 'auto 100%',
  backgroundColor: '#040404',
  position: 'fixed',
  width: '100%',
  height: '100vh',
  top: '0',
  left: '0',
  zIndex: '0',
})

const socialBloc = css({
  color: '#fff',
  position: 'absolute',
  top: '5px',
  left: '5px',
  zIndex: '999',
  '-webkit-transform': 'rotate(270deg)',
  '-moz-transform': 'rotate(270deg)',
  '-ms-transform': 'rotate(270deg)',
  '-o-transform': 'rotate(270deg)',
  transform: 'rotate(270deg)',
})

And the Html:

<PageLayout pageName="Index">
  <div className={socialBloc}>
     <Link prefetch target='_blank' href='*'><a className={a} target="_blank">Link</a</Link>
     <Link prefetch target='_blank' href='*'><a className={a} target="_blank">Link</a</Link>
  </div>
  <div className={background}>
  </div>
</PageLayout>

It's working great with horizontal (no rotation) but when I apply the rotation my text is over..

Thanks for help

Answer:1

I have made your socialBloc an inline block so that it's length is limited.

Next, I translate it to the left to make the rightmost corner be where the left one was, and rotate it around the left top center:

.socialBloc {
  display: inline-block;
  font-size: 36px;
  background-color: yellow;
  transform-origin: left top;
  transform: rotate(270deg) translateX(-100%);
}
<div class="socialBloc">
  <a target='_blank' href="#link">Link</a>
  <a target='_blank' href="#link">Link</a>
</div>
Answer:2

Instead of

transform: rotate(270deg);

you can use:

writing-mode: vertical-rl;

The latter is explicitly intended for manipulating the display of text.


Working Example:

.socialBloc {
font-size: 36px;
writing-mode: vertical-rl;
}
<div class="socialBloc">
<a target='_blank' href="#link">Link</a>
<a target='_blank' href="#link">Link</a>
</div>
Answer:3

Without a visual example to go by I can only guess your issue, but perhaps using transform-origin would help. This will allow you to define a point on the element other than the centre for the transform to take effect.

Answer:4

Maybe the answer is obvious, but I don't get it. Why are the Dates in the Code Snippet different? Does the format say something about the hours as well? console.log("2017-1-9 -->") console....

Maybe the answer is obvious, but I don't get it. Why are the Dates in the Code Snippet different? Does the format say something about the hours as well? console.log("2017-1-9 -->") console....

  1. what does same date mean

I am learning javascript and at the same time trying to create a simple script that allows you to type a foreign language on a web browser with your keyboard. So, when you type a for example, there ...

I am learning javascript and at the same time trying to create a simple script that allows you to type a foreign language on a web browser with your keyboard. So, when you type a for example, there ...

i have a code that list below option in . when i select other, then combo box should convert into text. i tried with some script using onchange fucntion function chargeother(ele){ if(ele....

i have a code that list below option in . when i select other, then combo box should convert into text. i tried with some script using onchange fucntion function chargeother(ele){ if(ele....

  1. change combo box text size
  2. how to change text in combobox
  3. change combobox text color
  4. xaml change combobox text color
  5. jquery change text combobox

I am new to JavaScript and trying to find the difference between two JSON Objects. The structure of the JSON object and its data is shown below. I got a code online which works for a normal JSON ...

I am new to JavaScript and trying to find the difference between two JSON Objects. The structure of the JSON object and its data is shown below. I got a code online which works for a normal JSON ...

  1. compare json objects java
  2. compare json objects javascript
  3. compare json objects online
  4. compare json objects python
  5. compare json objects c#
  6. compare json objects nodejs
  7. compare json objects powershell
  8. compare json objects php
  9. compare json objects jackson
  10. compare json objects jquery
  11. compare json objects
  12. compare two json objects java
  13. compare two json objects javascript
  14. compare two json objects
  15. compare two json objects online
  16. compare 2 json objects java
  17. compare 2 json objects
  18. compare 2 json objects javascript
  19. compare two json objects python