码迷,mamicode.com
首页 > 其他好文 > 详细

块级元素 和行内元素的区别

时间:2019-06-29 17:43:54      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:16px   text   www   span   内容   gre   round   htm   font   

块级元素会独占一行,默认情况下,其宽度自动填满其父元素宽度,行内元素不会独占一行

相邻的行内元素会排列在同一行里,

直到一行排不下,才会换行,其宽度随元素的内容而变化

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>简单实例</title>
    </head>
    <style type="text/css">
        p{background: red;}
        div{background: yellow;}
        span{background: blue;}
        strong{background: green;}
    </style>
    <body>
        <p>块级元素 p</p><div>块级元素 div</div><span>行内元素 span</span><strong>
            行内元素 strong</strong>
        
    </body>
</html>

技术图片

块级元素 和行内元素的区别

标签:16px   text   www   span   内容   gre   round   htm   font   

原文地址:https://www.cnblogs.com/fdxjava/p/11107255.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!