[CSS] 手機版頁面 側邊選單


京都 花見小路
首頁
內容 圖文交錯
左側選單 
右側選單
來做一下手機版的網頁好了,想玩玩側邊 Menu。
頂部的橫幅選單
  1. header {
  2. width: 100%;
  3. position: fixed;
  4. top: 0;
  5. z-index: 9;
  6. .top-bar {
  7. width: inherit;
  8. display: flex;
  9. justify-content: space-between; /*分散排列*/
  10. .icon {
  11. width: 30px;
  12. height: 30px;
  13. }
  14. }
  15. }
中間內容大致上的設定
  1. //內容版面
  2. .container {
  3. padding-top: 50px;/* 保留頭部空間 */
  4. width: inherit;
  5. overflow: hidden;
  6. position: relative;/*基本設定*/
  7. .content {
  8. position: relative;/*基本設定*/
  9. background-color: inherit;
  10. }
  11. }
  1.  
左右選單主要設定
  1. .right-menu, .left-menu {
  2. position: fixed;
  3. z-index: 9;
  4. top: 0;
  5. bottom:0;/* 讓選單高度到內容的最底 */
  6. overflow: auto;/* 捲軸顯示(重要) */
  7. width: 280px;
  8. background: #bbbbbb;
  9. }
左邊往左推
  1. .left-menu {
  2. top: 0;
  3. left: -280px;/* 擺在畫面外 */
  4. transform: translate3d(0,-50px,0);/* 設定位移動畫 */
  5. transition: all 500ms ease-in-out;/* 過場方式 */
  6. }
右邊的話也是大同小異。

接下來是處理圖文交錯
  1. section:nth-child(2n) {
  2. //處理 Safari - rotate3d支援問題
  3. -webkit-perspective: 400px;
  4. div{
  5. transform: rotate3d(0,1,0,180deg);
  6. //文字的部分再轉正
  7. .feed {
  8. -webkit-transform: rotate3d(0,1,0,180deg);
  9. -moz-transform: rotate3d(0,1,0,180deg);
  10. -o-transform: rotate3d(0,1,0,180deg);
  11. transform: rotate3d(0,1,0,180deg);
  12. }
  13. }
  14. }

完成作品: mobile webpage - yoga paradise