HTML中如何让图片按原有大小比例展示?

html-css07

HTML中如何让图片按原有大小比例展示?,第1张

<div class="cooperation_one">

        <div class="cooperation_people">

            <span>

                    <img src="./static/imgs/pages/coo/cooperation_4.png" alt="" srcset="">

                </span>

        </div>

    </div>

.cooperation_one{

    width: 30%

    height: 100px           // 保证所有的图片高度固定

    line-height: 100px    //垂直居中

    display: flex              //弹性布局保证左右居中

    justify-content: space-around

}

.cooperation_people{

    display: table-cell           //保证每行的高度是一样的

    text-align: center           

    vertical-align:middle

}

.cooperation_people span{

    display: block

    width: 100%

    margin: 0 auto

}

.cooperation_people img{

    max-width: 100%

    max-height: 100%

}

操作如下:

图像文件和http、html文件位于同一文件夹:只需输入图像文件的名称即可展示。

图像文件位于http、html文件的下一级文件夹:输入文件夹名和文件名,之间用“/”隔开,点击即可展示。

图像文件位于http、html文件的上一级文件夹:在文件名之前加入“../” ,如果是上两级,则需要使用 “../ ../”,以此类推,点击即可展示。

http,html指的是路径,当我们需要在网页中插入图像等外部文件,此时就需要采用“路径”的方式来指定文件的位置。