Web前端:HTML+CSS百分比佈局,內容(文字和圖片等)大小隨着放大縮小而縮放

以下是一個Dome

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style type="text/css">
        * {
            margin: 0px;
            padding: 0px;
            list-style-type: none;
            text-decoration: none;
        }

        #Div {
            width: 90%;
            border: 1px solid #000;
            margin: 0px auto;
            overflow: auto;
        }

        .d1 {
            width: 30%;

           border: 1px solid #f00;
            float: left;
            margin-left: 2.25%;
            margin-top:2%;
        }
    </style>
</head>
<body>
    <div id="Div">
        <div class="d1">2312313</div>
        <div class="d1">213123123</div>
        <div class="d1">123123123</div>
        <div class="d1">21312312</div>
        <div class="d1"></div>
        <div class="d1"></div>
        <div class="d1"></div>
        <div class="d1"></div>
        <div class="d1"></div>
    </div>
</body>
</html>

所以我們要注意哪些尼?

 

第一點 注意不使用絕對寬度

width:auto; / width:XX%;  

 

第二點 注意字體大小

字體大小是頁面默認大小的100%,即16像素
字體不要使用絕對大小"PX",要使用相對大小“REM”

font-size

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章