Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS 基础篇(6):HTML元素类型 #13

Open
rhymecoding opened this issue Aug 5, 2018 · 0 comments
Open

CSS 基础篇(6):HTML元素类型 #13

rhymecoding opened this issue Aug 5, 2018 · 0 comments
Labels

Comments

@rhymecoding
Copy link

本篇为下一篇盒模型做准备。

HTML元素分为两种:块级元素(block-level)和内联级元素(inline-level)。

块级元素与display:block

块级元素与display:block并不是对应的,凡是独占一行的元素都算是块级元素,所以display:list-item/table也是块级元素。

利用块级元素独占一行的特性,结合伪元素可以清浮动

.clearfix::after {
  content: '';
  display: block; // 只要是块级元素就行,比如还可以是table
  clear: both;
}

块级元素与内联级元素的区别

1.块级元素独占一行;
2.块级元素可以设置width、height,内联级元素不行;
3.块级元素可以设置margin和padding,内联级元素只能设置水平方向的margin(margin-left、margin-right)和padding(padding-left、padding-right);

@shiiiiiiji shiiiiiiji added this to the Contributions milestone Aug 6, 2018
@shiiiiiiji shiiiiiiji removed this from the Contributions milestone Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants