GithubHelp home page GithubHelp logo

blog's Introduction

blog's People

Contributors

wstreet avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

blog's Issues

面试题收藏

css面试题收集

1. 介绍一下标准的CSS的盒子模型?与低版本IE的盒子模型有什么不同的?

  • 盒模型由content、padding、border、margin组成,
  • 标准模型中盒模型的宽高只是内容(content)的宽高,
  • IE模型中盒模型的宽高是内容(content)+填充(padding)+边框(border)的总宽高

2. box-sizing属性

  • 用来控制元素的盒子模型的解析模式,默认为content-box
  • context-box:W3C的标准盒模型,设置元素的 height/width 属性指的是content部分的高/宽
  • border-box:IE传统盒子模型。设置元素的height/width属性指的是border + padding + content部分的高/宽

3. 解释一下BFC

定义: 块级格式化上下文,它是一个独立的渲染区域,规定了内部的Block-level Box如何布局,并且与这个区域外部毫不相干。
规则:

  • 内部的Box会在垂直方向,一个接一个地放置
  • Box垂直方向的距离由margin决定。属于同一个BFC的两个相邻Box的margin会发生重叠
  • 每个元素的margin box的左边, 与包含块border box的左边相接触(对于从左往右的格式化,否则相反)。即使存在浮动也是如此。
  • BFC的区域不会与float box重叠。
  • BFC就是页面上的一个隔离的独立容器,容器里面的子元素不会影响到外面的元素。反之也如此。
  • 计算BFC的高度时,浮动元素也参与计算

4. 那些元素会生成BFC
根元素
float属性不为none
position为absolute或fixed
display为inline-block, table-cell, table-caption, flex, inline-flex
overflow不为visible

5. 解决垂直外边距合并的几种办法

  1. 父容器:border:1px solid;(不能是0px)
  2. 父容器:overflow: hidden;(或auto)
  3. 父容器:padding:1px;(不能是0或auto,其他的任意数值都可以)
  4. 父容器或子容器: float:left;(不能是auto)
  5. 父容器或子容器:position:absolute;
  6. 子容器:display:inline-block;(或是inline-table)
  7. 相邻元素:任意一个添加float:left(不能是auto)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.