• Web前端面试指导(十七):一个满屏 品 字布局 如何设计?


    题目点评

    这道题目有可能是笔试题,有可能面谈的时候进行叙述,如果是笔试题要求对css样式代码非常熟练,如果是面谈叙述,就需要你的表达能力非常强,要抓住要点,把需要用到的技能点讲清楚就可以了。

    需要用到技术

    1.     元素水平居中对齐

    1)        使用margin对齐(推荐)

    2)        使用left:50%

    3)        使用text-align

    2.  元素对相对窗口定位

    1)        使用filxed(推荐)

    2)        使用absolute定位

    3)        使用html和body的width和height填?这个窗口

    3.     元素左右定位

    1)        使用float左右浮动

    2)        使用绝对定位进行左右定位(推荐)

    具体实现的代码

    html代码

    1. <div class="main">  
    2.  <div class="wrapper-up">  
    3.    <div class="div-square-up"></div>  
    4.  </div>  
    5.  <div class="wrapper-down">  
    6.    <div class="div-square-left"></div>  
    7.    <div class="div-square-right"></div>  
    8.  </div>  
    9. </div>   

    CSS样式

    1. body{  
    2.           height: 1200px;  
    3.       }  
    4.       .main {  
    5.           position: fixed;  
    6.           left: 0;  
    7.           top: 0;  
    8.           height: 100%;  
    9.            100%;  
    10.       }  
    11.       .wrapper-up {  
    12.           height: 50%;  
    13.       }  
    14.   
    15.       .wrapper-down {  
    16.           height: 50%;  
    17.           position: relative;  
    18.       }  
    19.       .div-square-up {  
    20.            50%;  
    21.           margin: auto;  
    22.           border: 2px solid red;  
    23.           height: 96%;  
    24.           box-sizing: border-box;  
    25.       }  
    26.   
    27.       .div-square-left {  
    28.           position: absolute;  
    29.           left: 0;  
    30.            48%;  
    31.           height: 100%;  
    32.           box-sizing: border-box;  
    33.           border: 2px solid red;  
    34.       }  
    35.   
    36.       .div-square-right {  
    37.           position: absolute;  
    38.           right: 0;  
    39.            48%;  
    40.           height: 100%;  
    41.           border: 2px solid red;  
    42.           box-sizing: border-box;  
    43.       }  


  • 相关阅读:
    [转]ThinkCMF框架任意内容包含漏洞分析复现
    nodejs环境安装
    ffmpeg+nginx-rtmp-module
    activemq安装
    mysql审计插件
    sql优化工具SQLAdvisor的安装
    Harbor安装(docker-compose) -- 企业级Registry仓库
    在CentOS上部署kubernetes1.9.0集群
    3-基础概念(数据模型、时序 4 种类型、作业和实例)
    1-什么是 Prometheus
  • 原文地址:https://www.cnblogs.com/zxwy/p/7028436.html
Copyright © 2020-2023  润新知