(橫豎屏切換/強制橫屏)CSS3 transform 怎樣才能中心旋轉(zhuǎn)?
問題描述
現(xiàn)在有一個canvas,我希望在(手機和平板)豎屏?xí)r能夠把它以中心作為旋轉(zhuǎn)原點旋轉(zhuǎn)90°(強制橫屏),但用了transform-origin,無論怎樣設(shè)置數(shù)值都不能達到目的,是我哪里搞錯了嗎?
附CSS代碼:
html, body{ width: 100%; height: 100%; margin: 0; padding: 0; background: #000000; -webkit-touch-callout: none; -webkit-user-select: none;}#main //div{ margin: 0; width: 100%; height: 100%; display: block; background: #000000; z-index: 10;}#live //在main里面的canvas{ background-size: cover; -moz-background-size: cover; -webkit-background-size: cover; -o-background-size: cover; z-index: 20;}@media all and (orientation : landscape){ #live {margin: 0 auto;padding: 0;display: block;background-size: cover;-moz-background-size: cover;-webkit-background-size: cover;-o-background-size: cover;z-index: 20; }}@media all and (orientation : portrait){ #live {transform: rotate(90deg);transform-origin: center center;-ms-transform: rotate(90deg); /* Internet Explorer 9 */-ms-transform-origin: center center; /* Internet Explorer 9 */-moz-transform: rotate(90deg); /* Firefox */-moz-transform-origin: center center; /* Firefox */-webkit-transform-origin: center center; /* Safari & Chrome */-webkit-transform: rotate(90deg); /* Safari & Chrome */-o-transform: rotate(90deg); /* Opera */-o-transform-origin: center center; /* Opera */margin: 0 auto;padding: 0;display: block;background-size: cover;-moz-background-size: cover;-webkit-background-size: cover;-o-background-size: cover;z-index: 20; }}
PS: W3C新出的屏幕方向API應(yīng)該可以實現(xiàn)這個功能,問題是實在太新了,現(xiàn)在的瀏覽器似乎都不支持,不信你們可以測試下。
(JavaScript)screen.orientation.lock('landscape');
問題解答
回答1:用transform的話貌似不太好吧,畢竟旋轉(zhuǎn)以后尺寸還得再改一遍
相關(guān)文章:
1. 致命錯誤: Class ’appfacadeTest’ not found2. 怎么php怎么通過數(shù)組顯示sql查詢結(jié)果呢,查詢結(jié)果有多條,如圖。3. 老師們php,插入數(shù)據(jù)庫mysql,都是空的,要怎么解決4. php點贊一天一次怎么實現(xiàn)5. sql語句 - 如何在mysql中批量添加用戶?6. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現(xiàn)存在即更新應(yīng)該使用哪個標(biāo)簽?7. 在應(yīng)用配置文件 app.php 中找不到’route_check_cache’配置項8. PHP類屬性聲明?9. 求大神支招,php怎么操作在一個html文件的<head>標(biāo)記內(nèi)添加內(nèi)容?10. phpstady在win10上運行
