利用 CSS3 旋轉 對根容器逆時針旋轉 90 度


利用 CSS3 旋轉 對根容器逆時針旋轉 90 度

// 利用 CSS3 旋轉 對根容器逆時針旋轉 90 度
var detectOrient = function () {
var width = document.documentElement.clientWidth,
    height = document.documentElement.clientHeight,
    $wrapper = document.getElementById("content"),
    style = "";
if (width >= height) { // 橫屏
    style += "width:" + width + "px;";  // 注意旋轉后的寬高切換
    style += "height:" + height + "px;";
    style += "-webkit-transform: rotate(0); transform: rotate(0);";
    style += "-webkit-transform-origin: 0 0;";
    style += "transform-origin: 0 0;";
    //console.log(1)
}
else { // 豎屏
    style += "width:" + height + "px;";
    style += "height:" + width + "px;";
    style += "-webkit-transform: rotate(90deg); transform: rotate(90deg);";
    // 注意旋轉中點的處理
    style += "-webkit-transform-origin: " + width / 2 + "px " + width / 2 + "px;";
    style += "transform-origin: " + width / 2 + "px " + width / 2 + "px;";
    //console.log(2)
}
$wrapper.style.cssText = style;
}
window.onresize = detectOrient;
detectOrient();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM