且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用CSS将所有html元素(整个页面)旋转90度?

更新时间:2023-11-11 08:32:04

这很有趣.小提琴

body{
    margin:0;
    overflow:hidden;
}
.wrapper{
    transform: rotate(90deg);
    transform-origin:bottom left;
    
    position:absolute;
    top: -100vw;
    left: 0;
    
    height:100vw;
    width:100vh;
    
    background-color:#000;
    color:#fff;

    overflow:auto;
}

<body>
    <div class='wrapper'>
        test<br />
        <hr />
        <div><hr /></div>
        <div><div><hr /></div></div>
        <div>ing</div>
    </div>
</body>

必须将内容包装在包装器 div 中,将 body overflow 设置为隐藏,然后将内容向上滑动宽度......但是,嘿,它可以工作.

Had to wrap the content in a wrapper div, set body overflow to hidden, and slide the thing up by its width.... but hey, it works.

如果你很好奇,是的,我确实将高度设置为屏幕宽度,宽度设置为屏幕高度.使其干净利落地扩展自己.

If you're curious, yes, I did set height to screen-width and width to screen-height. Makes it scale itself cleanly.