1. 程式人生 > >最近面試前端面試題整理(css部分)

最近面試前端面試題整理(css部分)

type list 定位 text -c padding 面試 lang vertical

對最近面試的面試題坐下總結:

一,css部分

1,html元素的垂直居中

答案:

<div id="box">
   	  <div>
   	  	 測試
   	  </div>
   </div>
 #box{
      	 width: 200px;
      	 height: 200px;
      	text-align:center;
      	vertical-align: middle;
      	display: table-cell;
      }

2,css考的最多是flex;

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    .flex {
        display: flex;
        width: 800px;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .flex :nth-child(1) {
        flex: 1 1 300px;
    }

    .flex :nth-child(2) {
        flex: 2 2 200px;
    }

    .flex :nth-child(3) {
        flex: 3 3 400px;
    }
    </style>
</head>

<body>
    <ul class="flex">
        <li>a</li>
        <li>b</li>
        <li>c</li>
    </ul>
</body>

</html>

建議多看看這塊。

3,然後css還考察了清楚浮動的方法:

答案:

clear:both; overflow:hidden;偽類;

4,就是相對定位和絕對定位相關知識點

比如:position有哪些屬性值,每種的意義和用法。

最近面試前端面試題整理(css部分)