We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
总是独占一行。
满足:margin-left+padding-left+border-left+width+border-right+padding-right+margin-right = 父元素width
width,height,padding,margin都可以设置
宽度缺省是它的容器的100%
可以容纳内联元素和其他块元素
display属性用于设置元素的类型,主要就是block,inline,inline-block三种。前面提到的块级元素和行内元素分别就是block和inline。
该值是新增的值,是行内块元素。如input、img元素。
<!-- 写法一 --> <div> <a href="">我是a1</a> <a href="">我是a2</a> </div> <!-- 写法二 --> <div> <a href="">我是a1</a><a href="">我是a2</a> </div>
写法一中a1和a2之间会产生间隙。这是由于HTML 中的换行符、空格符、制表符等合并为空白符,字体大小不为 0 的情况下,空白符自然占据一定的宽度,使用inline-block或inline会产生元素间的空隙。而写法二没有换行就不会有空隙,但是不符合书写规范。
块级元素: div,form,h1,ul,ol,li,p
行内元素:img,span,input,select,a,em,b,button
The text was updated successfully, but these errors were encountered:
No branches or pull requests
块级元素和行内元素的定义
块级元素
总是独占一行。
width,height,padding,margin都可以设置
宽度缺省是它的容器的100%
可以容纳内联元素和其他块元素
行内元素
行内元素与块级元素的区别
display属性
display属性用于设置元素的类型,主要就是block,inline,inline-block三种。前面提到的块级元素和行内元素分别就是block和inline。
inline-block
该值是新增的值,是行内块元素。如input、img元素。
inline-block存在的问题:存在间隙
写法一中a1和a2之间会产生间隙。这是由于HTML 中的换行符、空格符、制表符等合并为空白符,字体大小不为 0 的情况下,空白符自然占据一定的宽度,使用inline-block或inline会产生元素间的空隙。而写法二没有换行就不会有空隙,但是不符合书写规范。
解决方法
常见的块级元素和行内元素
块级元素: div,form,h1,ul,ol,li,p
行内元素:img,span,input,select,a,em,b,button
The text was updated successfully, but these errors were encountered: