• 页面适配不同屏幕的例子


    <!DOCTYPE html>

    <html lang="en">

    <head>

     <meta charset="UTF-8">

     <title>Document</title>

    <style type="text/css">

    html,body{

    font: 100% 微软雅黑, 宋体, 新宋体;

    margin: 0; /* 最好将 body 元素的边距和填充设置为 0 以覆盖不同的浏览器默认值 */

    padding: 0;

    text-align: center; /* 在 IE 5* 浏览器中,这会将容器居中。文本随后将在 #container 选择器中设置为默认左对齐 */

    color: #FFF;

    height: 100%; /*这里将高度设置为100%是这个布局实现自适应高度的关键,只有这里设置了高度,下面div的高度设置才起作用*/

    #000;

    }

    #layout {

     100%;

    height: 100%;

    margin: 0px auto;

    }

    #header {

    height: 13%;

    #09F;

    }

    #container {

    height: 82%;

    #CC3;

    }

    #container #sidebar {

    height: 100%;

     20%;

    #C03;

    float: left;

    }

    #container #main {

    height: 100%;

     80%;

    #CFC;

    float: left;

    }

    #footer {

    height: 5%;

    #930;

    }

    .clearfloat { /* 此类应当放在 div 或 break 元素上,而且该元素应当是完全包含浮动的容器关闭之前的最后一个元素 */

    clear:both;

    height:0;

    font-size: 1px;

    line-height: 0px;

    }

    </style>

    </head>

    <body>

    <div id="layout">

    <div id="header">

    </div>

    <div id="container">

    <div id="sidebar">

    </div>

    <div id="main">

    </div>

    <br class="clearfloat" />

    </div>

    <div id="footer">

    </div>

    </div>

    </body>

    </html>

    适配不同屏幕html5

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">  

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>无标题文档</title>

    <link href="css/index.css" rel="stylesheet" type="text/css">

    <style>

    body{

     background:#eaeaea;

    }

    div{ 

    height:50%;

    50%; 

    position:fixed; 

    left:25%;

    top:20%; background:#eaeaea;

    }

    @media screen and(max-960px){

     #div{

      auto;

      height:auto;

      }

     }

    </style>

    </head>

    <body>

    <div>

    <img src="img/报错.png" height="100%" width="100%"/>

    </div>

    </body>

    </html>

  • 相关阅读:
    ARC 基础(上)
    将字符串写到屏幕上
    UIColor 详解
    the complexity is no longer O(lgn), right?
    [LeetCode] Sum Root to Leaf Numbers, Solution
    [LeetCode] Word Ladder II, Solution
    [Microsoft] Intealeaving of two given strings, Solution
    [Yahoo] Cloest palindrome number, Solution
    [LeetCode] Longest Consecutive Sequence, Solution
    Summary
  • 原文地址:https://www.cnblogs.com/lc93/p/7879073.html
Copyright © 2020-2023  润新知