博客园兼容手机端

第一步:在自定以的页面css代码中处理

@media screen and (max-width: 768px){
        #自定义的代码

}

我的是这样的

@media screen and (max-width: 768px){
    /*自定义的css规则*/
   #main, #mainContent{
        width: 100%;
    }
  /*在手机端限的时候隐藏导航栏、页面左/右侧、footer部分*/
    #sideBar, body > a, #navList, #navigator, .postDesc a, #homepage_top_pager,  #blogTitle h2{
        display: none;
    }
     #blogTitle {
         background:#000;
     }
    #blogTitle h1{
        margin-left:30%;
       
     }
    
    #blogTitle a{
        font-size: 30px;
         color:#fff;
    }
    #header{
        height: 65px;
    }
 #home{
        background-color: #68BCCA;
    }
    #home{
        background-image: none;
    }
    .postTitle a{
        font-size: 22px;
    }
    .postCon, .postCon a{
        font-size: 16px;
    }
    .day{
        margin: 1 2%;
    }
    .postCon a{
        padding-left: 0;
    }
    .postDesc{
        width: 100%;
        font-size: 12px;
    }
    #home{
        background-color:#e9e9e9;
    }
 
    .postBody{
        
    }
    #mainContent .postBody{
        width: 100%;
    }
    .post{
        padding: 0 4%;
    }
    .topicListFooter{
        width: 100%;
        text-align: center;
        padding: 0;
        height: 40px;
    }
   .pager{
        width: 100%;
        text-align: center;
        padding: 0;
        height: 40px;

     }
    .topicListFooter a:link{
        font-size: 18px;
    }



第二步:在页首 HTML 代码中添加
<script>
var content = 'width=device-width, initial-scale=1 user-scalable=no';
var viewport = document.createElement('meta');
viewport.setAttribute('name', 'viewport');
viewport.setAttribute('content', content);
document.head.appendChild( viewport );
</script>

 

 
posted @ 2020-03-22 18:10  时光一寸灰  阅读(237)  评论(1编辑  收藏  举报