HTML_CSS学习:CSS盒子模型

一、CSS中常用的长度单位

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS中常用的长度单位</title>
    <style>
        html{
            font-size: 40px;
        }
        #d1{
            /*第一种长度单位:px(像素)*/
            width: 200px;
            height: 200px;
            font-size: 20px;
            background-color: skyblue;

        }
        #d2{
            /*第二种长度单位:em(相对于当前元素的font-size的倍数)*/
            width: 10em;
            height: 10em;
            font-size: 20px;
            /*一层一层想上找*/
            background-color: yellow;

        }
        #d3{
            /*第三种长度单位:rem(相对于根元素的font-size的倍数)*/
            /*没写,默认16px*/
            width: 10rem;
            height: 10rem;
            /*font-size: 20px;*/
            font-size: 1rem;
            /*一层一层想上找*/
            background-color: green;

        }
        #d4{
            width: 200px;
            height: 200px;
            font-size: 20px;
            background-color: salmon;
        }
        .inside{
            /*第四种长度单位:%(相对其父元素的百分比)*/
            width: 50%;
            height: 25%;
            font-size: 150%;
            /*相对于复原素字体的150%*/
            background-color: mediumvioletred;
        }
        .test{
            font-size: 80px;
            text-indent: 2em;
            /*缩进两字符*/
            background-color: greenyellow;
        }

    </style>
</head>
<!--<body style="font-size: 50px;">-->
<body>
    <div id="d1">1</div>
    <hr>
    <div id="d2">2</div>
    <hr>
    <div id="d3">3</div>
    <hr>
    <div id="d4">
        <div class="inside">4</div>
    </div>
    <hr>
    <div class="test">好好学习,天天向上</div>

</body>
</html>

显示结果:


二、元素的显示模式

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素的显示模式</title>
<!--    块元素在页面中独占一行,不会与任何元共用一行,是从上到下排列的-->
<!--    默认宽度:撑满父元素-->
<!--    默认高度:由内容撑开-->
<!--    可以通过CSS设置高度-->
    <style>
        body{
            /*margin: 0;*/
            /*margin: 可以让块全面铺开,没有缝隙*/
            background-color: #999ff0;
        }
        div{
            width: 200px;
            height: 200px;
        }
        #d1{
            background-color: green;
        }
        #d2{
            background-color: #cb7326;
        }
        #d3{
            background-color: #07e0c0;
        }
        .one{
            background-color: #0000cc;
        }
        .two{
            background-color: #63c61c;
        }
        span{
            width: 200px;
            height: 200px;
        }
        img{
            width: 50px;
        }
    </style>
</head>
<body>
    <div id="d1">山回路转不见君</div>
    <div id="d2">雪上空留马行处</div>
    <div id="d3">风里雨里我在信阳农林等你</div>
    <hr>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <span class="one">人之初</span>
    <span class="two">性本善</span>
    <hr>
    <img src="../pictures/喜羊羊.jpg" alt="喜羊羊">
    <img src="../pictures/喜羊羊.jpg" alt="喜羊羊">
    <img src="../pictures/喜羊羊.jpg" alt="喜羊羊">
<!--    行内元素(内联元素)-->
<!--    行内块元素(内联块元素)-->
<!--    在页面中不独占一行,一行中不能容纳下的行内元素,会在下一行继续从左到右排列-->
<!--    默认宽度:撑满父元素-->
<!--    默认高度:由内容撑开-->
<!--    可以通过CSS设置高度-->
</body>
</html>

显示结果:

三、总结各元素的显示模式

块元素:
    1.主题结构标签:<html>、<body>
    2.排版标签:<h1>-<h6>、<hr>、<p>、<pre>、<div>
    3.列表标签:<ul>、<ol>、<li>、<dt>、<dd>
    4.表格相关标签:<table>、<tbody>、<thead>、<tfoot>、<tr>、<caption>
    5.<form>、<option>
行内元素:
    1.文本标签:<br>、<em>、<strong>、<sup>、<sub>、<del>、<ins>
    2.<a>与<label>
行内块元素:
    1.图片:<img>
    2.单元格:<td>、<th>
    3.表单控件:<input>、<textarea>、<select>、<button>
    4.框架标签:<iframe>

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>总结各元素的显示模式</title>
    <style>
        #s1{
            background-color: #999ff0;
        }
        /*#d1{*/
        /*    background-color: #999ff0;*/
        /*}*/
        #d2{
            background-color: #0dcaf0;
        }
    </style>
</head>
<body>
<!--    <div id="d1">123</div>-->
    <span id="s1">123</span><br><br>
    <div id="d2">456</div>

</body>
</html>

显示结果:

四、修改元素的显示模式

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改元素的显示模式</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            font-size: 20px;
            /*display: block;*/
            display: inline-block;
            /*display: inline;*/
        }
        #d1{
            background-color: skyblue;
        }
        #d2{
            background-color: #a2eb87;
        }
        #d3{
            background-color: #c887eb;
        }
        a{
            width: 200px;
            height: 200px;
            font-size: 20px;
            /*display: block;*/
            display: none;
        }
        #s1{
            background-color: springgreen;
        }
        #s2{
            background-color: #ae0f61;
        }
        #s3{
            background-color: #95ae25;
        }

    </style>
</head>
<body>
    <div id="d1">你好1</div>
    <div id="d2">你好2</div>
    <div id="d3">你好3</div>
    <hr>
    <a id="s1" href="https://www.baidu.com">去百度</a>
    <a id="s2" href="https://www.jd.com">去京东</a>
    <a id="s3" href="https://www.toutiao.com">去头条</a>

</body>
</html>

显示结果:

五、盒子模型的组成部分

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>盒子模型的组成部分</title>
    <style>
        div{
            /*内容区的宽*/
            width: 400px;
            /*内容区的高*/
            height: 400px;
            /*内边距 设置的背景颜色会天从内边距区域*/
            padding: 20px;
            /*border: 10px dashed black;*/
             /*边框 设置的背景颜色会天从边框区域*/
            border: 10px solid transparent;
            /*外边距 只影响盒子的位置,不影响盒子大小*/
            margin: 50px;
            font-size: 20px;
            background-color: #999ff0;

        }
    </style>
</head>
<body>
    <div>你好啊</div>

</body>
</html>

显示结果:

六、盒子的内容区

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>盒子的内容区</title>
    <style>
        div{
            width: 800px;
            /*min-width: 600px;*/
            /*max-width: 1000px;*/
            height: 200px;
            /*min-height: 可以被内容撑开*/
            /*min-height: 50px;*/
            /*max-height: 400px;文字太多会超出范围,会在外面显示出来*/
            /*max-height: 400px;*/
            background-color: #0dcaf0;
        }
    </style>
</head>
<body>
    <div>In the heart of a bustling city, there lies a hidden garden that few have ever discovered. Tucked away from the noise and chaos of urban life, this secret oasis is a place of tranquility and peace. The garden is a riot of colors, with flowers of every hue blooming in profusion. Birds flit from branch to branch, their songs adding to the symphony of nature's music.

A winding path leads through the garden, past bubbling fountains and shady groves where one can sit and contemplate the beauty of the world. The air is filled with the scent of jasmine and roses, a heady perfume that intoxicates the senses. Butterflies dance in the sunlight, their delicate wings shimmering like jewels.

At the center of the garden stands a majestic oak tree, its branches reaching towards the sky like outstretched arms. Beneath its leafy canopy, a stone bench offers a place to rest and reflect. Here, the cares of the world seem to melt away, replaced by a sense of calm and serenity.

As the sun sets in the distance, casting a golden glow over the garden, one can't help but feel a deep sense of gratitude for this hidden paradise. In a world filled with noise and distractions, it is a rare gift to find such a peaceful sanctuary.

And so, as evening falls and the stars begin to twinkle in the sky, the garden remains a haven of beauty and tranquility, a secret refuge for those who seek solace in the midst of chaos.
    In the heart of a bustling city, there lies a hidden garden that few have ever discovered. Tucked away from the noise and chaos of urban life, this secret oasis is a place of tranquility and peace. The garden is a riot of colors, with flowers of every hue blooming in profusion. Birds flit from branch to branch, their songs adding to the symphony of nature's music.

A winding path leads through the garden, past bubbling fountains and shady groves where one can sit and contemplate the beauty of the world. The air is filled with the scent of jasmine and roses, a heady perfume that intoxicates the senses. Butterflies dance in the sunlight, their delicate wings shimmering like jewels.

At the center of the garden stands a majestic oak tree, its branches reaching towards the sky like outstretched arms. Beneath its leafy canopy, a stone bench offers a place to rest and reflect. Here, the cares of the world seem to melt away, replaced by a sense of calm and serenity.

As the sun sets in the distance, casting a golden glow over the garden, one can't help but feel a deep sense of gratitude for this hidden paradise. In a world filled with noise and distractions, it is a rare gift to find such a peaceful sanctuary.

And so, as evening falls and the stars begin to twinkle in the sky, the garden remains a haven of beauty and tranquility, a secret refuge for those who seek solace in the midst of chaos.</div>
</body>
</html>

显示结果:

七、关于默认宽度

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>关于默认宽度</title>
    <style>
        div{
            /*width: 400px;*/
            height: 200px;
            margin: 50px;
            /*盒子的整体宽度包含border*/
            border: 5px solid black;
            padding: 5px;
            background-color: hotpink;
        }
    </style>
</head>
<body>
    <div>你好啊</div>

</body>
</html>

显示结果:

八、盒子的内边距_padding

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>盒子的内边距_padding</title>
    <style>
        #d1{
            width: 400px;
            height: 400px;
            /*!*左侧内边距*!*/
            /*!*padding: 20px;*!*/
            /*padding-left: 20px;*/
            /*!*上内边距*!*/
            /*padding-top: 30px;*/
            /*!*右侧内边距*!*/
            /*padding-right: 40px;*/
            /*!*底部内边距*!*/
            /*padding-bottom: 50px;*/
            /*复合属性,写一个值,含义:四个方向的内边距是一样的*/
            /*padding: 20px;*/
            /*复合属性:写两个值,含义:上下、左右*/
            /*padding:10px 20px;*/
            /*符合属性:写三个值,含义:上、左右、下*/
            /*padding:10px 20px 30px;*/
            /*复合属性:写写四个值,含义:上、右、下、左*/
            /*padding:10px 20px 30px 40px;*/


            font-size: 20px;
            background-color: skyblue;
        }
        span{
            background-color: #999ff0;
            font-size: 20px;
            padding-left: 20px;
            padding-right: 20px;
            padding-top: 20px;
            padding-bottom: 20px;
        }
        img {
            width: 300px;
            padding: 50px;
        }
    </style>
</head>
<body>
    <div id="d1">你好啊</div>
    <hr>
    <span>我很好</span>
    <div>In the heart of a bustling city, there lies a hidden garden that few have ever discovered</div>
    <hr>
    <img src="../pictures/喜羊羊.jpg"alt="">
    <div>喜羊羊在干啥?</div>

</body>
</html>

显示结果:

九、盒子的边框_border

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>盒子的边框_border</title>
    <style>
        div{
            width: 400px;
            height: 400px;
            background-color: #0000cc;
            /*border-width: 10px;*/

            border-left-width: 10px;
            border-right-width: 20px;
            border-top-width: 30px;
            border-bottom-width: 40px;

            border-left-color: #0ebe90;
            border-right-color: #8fbe0e;
            border-top-color: #16175d;
            border-bottom-color: #670e58;

            border-left-style: solid;
            border-right-style: dashed;
            border-top-style: double;
            border-bottom-style: dotted;
            /*border: 10px solid red;*/

            /*border-color: rosybrown;*/
            /*border-width: 80px;*/
            /*border-style: dashed;*/

            border-left: 50px solid peru;
            border-right: 50px dashed #24c661;
            border-top: 50px double #8e69ca;
            border-bottom: 50px dotted #d07ecf;
        }
    </style>
</head>
<body>
    <div>你好啊</div>
</body>
</html>

显示结果:

十、盒子的外边距_margin

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>盒子的外边距_margin</title>
    <style>
        div{
            width: 400px;
            height: 400px;


            /*margin-left: 10px;*/
            /*margin-right: 20px;*/
            /*margin-top: 30px;*/
            /*margin-bottom: 40px;*/

            /*margin: 50px;*/
            /*margin: 10px 20px;*/
            /*margin: 10px 20px 30px;*/
            /*margin: 10px 20px 30px 40px;*/


            background-color: green;
        }
    </style>
</head>
<body>
    <div>信阳农林学院欢迎你</div>

</body>
</html>

显示结果:

十一、margin的注意事项1

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>margin的注意事项1</title>
    <style>
        .outer{
            width: 400px;
            height: 400px;
            padding: 50px;
            background-color: #5dcd2d;
        }
        .inner{
            width: 100px;
            height: 100px;
            margin: 100px;
            background-color: #2dbacd;
        }
    </style>
</head>
<body>
<!--    子元素的margin是参考父元素的centent计算的-->
    <div class="outer">
        <div class="inner"></div>

    </div>

</body>
</html>

显示结果:

十二、margin的注意事项2

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>margin的注意事项2</title>
    <style>
        img{
            width: 300px;
        }
        .box{
            width: 200px;
            height: 200px;
        }
        .box1{
            background-color: skyblue;
        }
        .box2{
            background-color: #2ea730;
            margin-top: 50px;
            margin-bottom: 50px;
        }
        .box3{
            background-color: #a5329a;
        }
        .second{
            margin-left: 50px;
            margin-right: 50px;
        }
    </style>
</head>
<body>
<!--    上margin、左margin会影响自身的位置,下margin、右margin会影响兄弟元素额位置-->
    <div class="box box1">1</div>
    <div class="box box2">2</div>
    <div class="box box3">3</div>
    <hr>
    <img src="../pictures/喜羊羊.jpg" alt="">
    <img src="../pictures/喜羊羊.jpg" alt="">
    <img src="../pictures/喜羊羊.jpg" alt="">

</body>
</html>

显示结果:

十三、margin的注意事项3

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>margin的注意事项3</title>
    <style>
        img{
            width: 300px;
            margin: 50px;
        }
        #d1{
            width: 400px;
            height: 400px;
            margin: 50px;
            background-color: #999ff0;
        }
        .one{
            background-color: skyblue;
        }
        .two{
            background-color: skyblue;
            margin-left: 50px;
            margin-right: 50px;
            margin-top: 3000px;
            margin-bottom: 3000px;
        }
        .three{
            background-color: skyblue;
        }
    </style>
</head>
<body>
<!--    对于行内原宿来说,左右的margin是可以完美设置的,上下的margin设置后是无效的-->
    <div id="d1">信阳农林学院欢迎你</div>
    <div>欢迎来信阳</div>
    <hr>
    <img src="../pictures/喜羊羊.jpg" alt="喜羊羊">
    <div>欢迎来信阳</div>
    <hr>
    <span class="one">人之初</span><span class="two">性本善</span><span class="three">性相近</span>
    <div>欢迎来信阳</div>
</body>
</html>

显示结果:

十四、margin的注意事项4

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>margin的注意事项4</title>
    <style>
        div{
            width: 800px;
            height: 100px;
            /*margin-left: auto;*/
            /*margin-right: auto;*/
            /*margin-top: auto;*/
            /*margin-bottom: auto;*/
            margin: 100px auto;
            background-color: deeppink;
        }
        span{
            background-color: #0dcaf0;
            /*margin: 100px auto;*/
              margin: 0 auto;
        }
    </style>
</head>
<body>
<!--    margin的值也可以是auto,给一个块级元素左右margin设置auto可以实现该元素在其父元素内水平居中-->
    <div>信息工程学院</div>
    <span>好好学习,天天向上</span>

</body>
</html>

显示结果:

十五、margin的注意事项5

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>margin的注意事项</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
        }
        .box1{
            background-color: #999ff0;
        }
        .box2{
            margin-top: -50px;
            background-color: #8fbf3f;
        }
    </style>
</head>
<body>
    <div class="box box1">1</div>
    <div class="box box2">2</div>

</body>
</html>

显示结果:

十六、_CSS_margin塌陷问题

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>margin塌陷问题</title>
    <style>
        .outer{
            width: 400px;
            /*height:400px;*/
            background-color: #1c80d9;
            /*第一种解决方案*/
            /*border:1px solid #2ba5a5;*/
            /*第二种解决方案*/
            /*padding:1px ;*/
            /*第三种解决方案*/
            /*border: 10px solid transparent;*/
            overflow: hidden;
            /*第一个子元素的上margin会作用在父元素上,最后一个子元素的下margin会作用在父元素上*/
        }

        .inner1{
            width:100px;
            height:100px;
            background-color: yellow;
            /*margin-bottom: 50px;*/
            margin-top: 50px;
        }
        .inner2{
            width:100px;
            height:100px;
            background-color: red;
            margin-bottom: 50px;
        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="inner1">inner1</div>
        <div class="inner2">inner2</div>

    </div>

    <div>我是一段测试的文字</div>

</body>
</html>

显示结果:

十七、margin合并问题

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>margin合并问题</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
        }
        .box1{
            background-color: red;
            margin-bottom: 50px;
        }
        .box2{
            background-color: blue;
            margin-top:50px;
            /*float: left;*/
        }
        .test{
            width: 200px;
            height: 200px;
            display: inline-block;
        }
        .testa{
            background-color: yellow;
            /*margin-bottom: 50px;*/
        }
        .testb{
            background-color: green;
            /*margin-top:50px;*/
        }
    </style>
</head>
<body>
<div class="outer">
    <div class="box box1">1</div>
    <div class="box box2">2</div>
    <hr>
    <div class="test testa">a</div>
    <div class="test testb">b</div>
</div>

</body>
</html>

显示结果:

十八、处理内容的溢出

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>处理内容的溢出</title>
    <style>
        #d1{
            width: 200px;
            height: 200px;
            background-color: red;
            /*overflow: hidden;*/
            /*overflow: scroll;*/
            /*overflow: auto;*/
            overflow-x: hidden;
            overflow-y: scroll;
        }
        #d2{
            width: 400px;
            background-color: blue;
        }
    </style>
</head>
<body>
    <div id="d1">lorem ipsum dolor sit amet, consectetur adipisicing elit.
        lorem ipsum dolor sit amet, consectetur adipisicing elit.
        <div id="d2">lorem ipsum dolor sit amet, consectetur adipisicing elit.lorem ipsum dolor sit amet, consectetur adipisicing elit.lorem ipsum dolor sit amet, consectetur adipisicing elit.lorem ipsum dolor sit amet, consectetur adipisicing elit.</div>
        lorem ipsum dolor sit amet, consectetur adipisicing elit.
        lorem ipsum dolor sit amet, consectetur adipisicing elit.
        lorem ipsum dolor sit amet, consectetur adipisicing elit.
        lorem ipsum dolor sit amet, consectetur adipisicing elit.
        Aliquam amet asperiores atque autem beatae cons
    </div>

</body>
</html>

显示结果:

十九、隐藏元素的两种方式

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>隐藏元素的两种方式</title>
    <style>
        .box{
            width: 200px;
            height: 200px;

            /*display: none;*/
            /*visibility: hidden;*/
        }
        .box1{
            background-color: blue;
            visibility: hidden;
        }
        .box2{
            background-color: #999ff0;
        }

    </style>
</head>
<body>
    <div class="box box1">1</div>
    <div class="box box2">2</div>


</body>
</html>

显示结果:

二十、样式的继承

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>样式的继承</title>
    <link rel="stylesheet" href="./p7.png">
    <style>
        #d1{
            height: 600px;
            padding: 50px;
            background-color: green;
        }
        #d2{

            height: 400px;
            background-color: red;
        }
        #d3{
            height: 200px;
            background-color: yellow;
            font-size: 40px;
            color: #4cbfbb;
            font-weight: bolder;
        }
    </style>
</head>
<body>
    <div id = "d1">
        <div id="d2">
            <div id="d3" style="font-family: 华文隶书">你好啊</div>
        </div>
    </div>

</body>
</html>

显示结果:

二十一、元素的默认样式

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素的默认样式</title>
    <style>
        #d1{
            font-size: 50px;
            color: #3057ba;
        }
        a {
            color: #3057ba;
            text-decoration: none;
            cursor: default;
        }
    </style>
</head>
<body>
    <div id="d1">
        <a href="https://www.baidu.com">去百度</a>
        <span>你好</span>
        <hr>
        <h1>一级标题</h1>
        <h2>二级标题</h2>
        <hr>
        <ul>
            <li>列表1</li>
            <li>列表2</li>
        </ul>
    </div>

</body>
</html>

显示结果:

二十二、布局技巧_1

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>布局技巧</title>
    <style>
        .outer{
            width: 400px;
            height: 400px;
            background-color: #f00;
            overflow:hidden;
        }
        .inner{
            width: 200px;
            height: 100px;
            /*padding: 5px;*/
            /*border: 5px solid #00f;*/
            background-color: #0f0;
            margin: 0 auto;
            margin-top:150px;
            text-align: center;
            line-height: 100px;


        }
    </style>
</head>
<body>
    <div class="outer">
        <div class="inner">inner</div>

    </div>

</body>
</html>

显示结果:

二十三、布局技巧_2

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>布局技巧</title>
    <style>
        .outer{
            width: 400px;
            height: 400px;
            background-color: #f00;
            text-align: center;
            line-height: 400px;
        }
        /*span{*/
        /*    background-color: green;*/
        /*    font-size: 20px;*/
        /*}*/
        .inner{
            background-color: #1c80d9;
            font-size: 20px;
        }

    </style>
</head>
<body>
    <div class="outer">
        <span class="inner">出来玩啊?</span>

    </div>

</body>
</html>

显示结果:

二十四、布局技巧_3

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>布局技巧</title>
    <style>
        .outer{
            width: 400px;
            height: 400px;
            background-color: #f00;
            text-align: center;
            line-height: 400px;
            font-size: 0px;
        }
        .image-resize{
            width: 100px;
            height: auto;
            vertical-align: middle;
        }
        span{
            font-size: 20px;
            background-color: green;
            vertical-align: middle;
            background-color: yellow;
        }
    </style>

</head>
<body>
    <div class="outer">
        <span>出来玩呀?</span>
        <img src="../pictures/喜羊羊.jpg" alt="" class="image-resize" >
    </div>


</body>
</html>

显示结果:

二十五、元素之间的空白问题

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素之间的空白问题</title>
    <style>
        div{
            height: 200px;
            background-color: #f00;
            font-size: 0px;
        }
        .s1{
            background-color: #0f0;
        }
        .s2{
            background-color: #00f;
        }
        .s3{
            background-color: #ff0;
        }
        .img1{
            width: 100px;
            height: auto;
        }
        .img2{
            width: 100px;
            height: auto;
        }
        .img3{
            width: 100px;
            height: auto;
        }
        span{
            font-size: 20px;
        }
    </style>

</head>
<body>
    <div>
        <span class = "s1">人之初</span>
        <span class = "s2">性本善</span>
        <span class = "s3">性相近</span>
        <hr>
        <img src="../pictures/喜羊羊.jpg" alt="" class="img1">
        <img src="../pictures/喜羊羊.jpg" alt="" class="img2">
        <img src="../pictures/喜羊羊.jpg" alt="" class="img3">

    </div>

</body>
</html>

显示结果:

二十六、行内块的幽灵空白问题

相关代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>行内块的幽灵空白问题</title>
    <style>
        div{
            width: 600px;
            background-color: #1c80d9;
            font-size: 0px;
        }
        img{
            height: 200px;
            vertical-align: bottom;
            /*display: block;*/
        }


    </style>
</head>
<body>
<div>
    <img src="../pictures/喜羊羊.jpg" alt="" style="width: 100px;height: auto;">
    <img src="../pictures/喜羊羊.jpg" alt="" style="width: 100px;height: auto;">rw
    <img src="../pictures/喜羊羊.jpg" alt="" style="width: 100px;height: auto;">xg
</div>

</body>
</html>

显示结果:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/591659.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

springboot+vue中小学文具商城购物系统网站

技术栈 前端&#xff1a;vue.jsElementUI 开发工具&#xff1a;IDEA 或者eclipse都支持 编程语言: java 框架&#xff1a; ssm/springboot 数据库: mysql 版本不限 数据库工具&#xff1a;Navicat/SQLyog都可以 详细技术&#xff1a;javaspringbootvueMYSQLMAVEN文具网站为用户…

【基于MAX98357的Minimax(百度)长文本语音合成TTS 接入教程】

【基于MAX98357的Minimax&#xff08;百度&#xff09;长文本语音合成TTS 接入教程】 1. 前言2. 先决条件2.1 硬件准备2.2 软件准备2.3 接线 3. 核心代码3.1 驱动实现3.2 代码解析 4. 播放文本5. 结论 视频地址&#xff1a; SeeedXIAO ESP32S3 Sense【基于MAX98357的Minimax&am…

8.MyBatis 操作数据库(进阶)

文章目录 1.动态SQL插入1.1使用注解方式插入数据1.2使用xml方式插入数据1.3何时用注解何时用xml&#xff1f;1.4使用SQL查询中有多个and时&#xff0c;如何自动去除多余and1.4.1方法一&#xff1a;删除and之后的代码如图所示&#xff0c;再次运行1.4.2方法二&#xff1a;加上tr…

MATLAB实现遗传算法优化同时取送货的车辆路径问题VRPSDP

同时取送货的车辆路径问题VRPSDP的数学模型如下: 模型假设 所有车辆的载重、容量等性能相同。每个客户的需求&#xff08;送货和取货量&#xff09;是已知的&#xff0c;且在服务过程中不会改变。车辆的行驶速度恒定&#xff0c;不考虑交通拥堵等实时路况变化。每个客户点只能…

【C语言】——结构体

【C语言】——结构体 一、结构体类型的声明1.1、结构体的声明1.2、结构体变量的创建和初始化1.3、结构体的特殊声明1.4、结构体的自引用1.5、结构体的重命名 二、 结构体的内存对齐2.1、对齐规则2.2、结构体对齐实践2.3、为什么存在内存对齐2.4、修改默认对齐数 三、结构体传参…

数据结构------栈的介绍和实现

目录 1.栈的一些初步认识 2.栈的实现 3.相关的函数介绍 &#xff08;1&#xff09;栈的初始化 &#xff08;2&#xff09;栈的销毁 &#xff08;3&#xff09;栈的数据插入 &#xff08;6&#xff09;判断是否为空 &#xff08;7&#xff09;栈的大小 4.栈的实现完整…

C语言例题31:在屏幕上显示一个菱形

题目要求&#xff1a;在屏幕上显示一个菱形 #include <stdio.h>void main() {int i, j;int x;printf("输入菱形行数(3以上的奇数&#xff09;&#xff1a;");scanf("%d", &x);//显示菱形上面的大三角形for (i 1; i < (x 1) / 2; i) {for (…

【R语言数据分析】相关性分析:pearson与spearman

相关性分析是探寻两个变量之间关联关系的分析方法&#xff0c;注意相关性分析仅仅针对连续型变量和有序分类变量&#xff0c;对于无需分类变量就不存在相关性分析了&#xff0c;而是通过差异分析来间接反映相关性。比如性别和身高的关系就无法做相关性分析&#xff0c;虽然我们…

RHCE shell-第一次作业

要求&#xff1a; 1、判断当前磁盘剩余空间是否有20G&#xff0c;如果小于20G&#xff0c;则将报警邮件发送给管理员&#xff0c;每天检査- 次磁盘剩余空间。 2、判断web服务是否运行(1、查看进程的方式判断该程序是否运行&#xff0c;2、通过查看端口的方式 判断该程序是否运…

动态规划——最短编辑距离

一、问题描述 最短编辑距离(Minimum Edit Distance)&#xff0c;也被称为Levenshtein距离&#xff0c;是一种计算两个字符串间的差异程度的字符串度量(string metric)。我们可以认为Levenshtein距离就是从一个字符串修改到另一个字符串时&#xff0c;其中编辑单个字符&#xff…

从零开始学AI绘画,万字Stable Diffusion终极教程(二)

【第2期】关键词 欢迎来到SD的终极教程&#xff0c;这是我们的第二节课 这套课程分为六节课&#xff0c;会系统性的介绍sd的全部功能&#xff0c;让你打下坚实牢靠的基础 1.SD入门 2.关键词 3.Lora模型 4.图生图 5.controlnet 6.知识补充 在第一节课里面&#xff0c;我们…

CPP#类与对象4

友元 关键字&#xff1a;friend 友元的实现&#xff1a;全局函数做友元&#xff1b; 类做友元&#xff1b; 成员函数做友元。 .1全局函数做友元 class Point { private:double x, y; public:Point(double xx, double yy); friend int Distance(Point &a, Point &b)…

关于win平台c语言引入开源库的问题与解决

许久不写博客&#xff0c;五一还在加班&#xff0c;就浅浅写一篇吧 最近除了做物联网平台 还对网关二次开发程序做了修改&#xff0c;网关的二次开发去年年底的时候做过&#xff0c;但是当时的逻辑不是十分完善&#xff0c;差不多已经过了半年了&#xff0c;很多细节已经忘记了…

探索APP托管服务分发平台的魅力 - 小猪APP分发平台(APP托管)

什么是APP托管服务分发平台 APP托管服务分发平台是一个集成了代码托管、构建集成、测试、发布和监控等全面性服务的平台。让开发者可以专注于创作探索APP托管服务分发平台的魅力 - 小猪APP分发平台&#xff0c;而不必花费太多精力在app的维护和分发上。 为什么要选择APP托管服…

D3CTF2024

文章目录 前言notewrite_flag_where【复现】D3BabyEscapePwnShell 前言 本次比赛笔者就做出两道简单题&#xff0c;但队里师傅太快了&#xff0c;所以也没我啥事。然后 WebPwn 那题命令行通了&#xff0c;但是浏览器不会调试&#xff0c;然后就简单记录一下。 note 只开了 N…

绘图神器===draw.io

文章目录 前言打开看看版本总结 前言 看到一个好玩的神器&#xff0c;Draw.io 看到一个网页draw.io&#xff0c;打开一看&#xff0c;还不错&#xff0c;是一款网页端的绘图平台。支持各种各样的绘制需求&#xff0c;像类图&#xff0c;流程图&#xff0c;泳道图&#xff0c;…

OpenCV如何模板匹配(59)

返回:OpenCV系列文章目录&#xff08;持续更新中......&#xff09; 上一篇&#xff1a;OpenCV如何实现背投(58) 下一篇 &#xff1a;OpenCV在图像中寻找轮廓(60) 目标 在本教程中&#xff0c;您将学习如何&#xff1a; 使用 OpenCV 函数 matchTemplate()搜索图像贴片和输入…

李沐-46 语义分割和数据集【动手学深度学习v2】

在语义分割中&#xff0c;不是一张图片分配一个label&#xff0c;而是为图片的每一个像素点分配一个label。假设我们输入的是RGB三通道的图片&#xff0c;即每个像素点颜色可以表示为(x, y, z)&#xff0c;那么为了给像素点打上label&#xff0c;我们需要构建一个映射关系&…

这是一个简单的照明材料网站,后续还会更新

1、首页效果图 代码 <!DOCTYPE html> <html><head><meta charset"utf-8" /><title>爱德照明网站首页</title><style>/*外部样式*/charset "utf-8";*{margin: 0;padding: 0;box-sizing: border-box;}a{text-dec…

24.哀家要长脑子了!

目录 1.594. 最长和谐子序列 - 力扣&#xff08;LeetCode&#xff09; 2.350. 两个数组的交集 II - 力扣&#xff08;LeetCode&#xff09; 3.554. 砖墙 - 力扣&#xff08;LeetCode&#xff09; 4.9. 回文数 - 力扣&#xff08;LeetCode&#xff09; 5.13. 罗马数字转整数 …
最新文章