Three pictures side by side based on html+css

Prepare project

Project development tools

Visual Studio Code 1.44.2
Version: 1.44.2
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T16:36:23.138Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8 : 7.8.279.23-electron .0
OS: Windows_NT x64 10.0.19044

Project structure

Insert image description here

index.html code is as follows

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片并排</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            display: flex;
            height: 200px;
            width: 300px;
            border: 1px solid #000;
            justify-content: space-between;
        }

        .box div {
            width: 100px;
        }

        img {
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="box">
        <div><img src="./images/1.jpg" alt=""></div>
        <div><img src="./images/1.jpg" alt=""></div>
        <div><img src="./images/1.jpg" alt=""></div>
    </div>
</body>

</html>

Summarize

This code can realize the side-by-side display of three pictures, which can fill the parent div box.

Guess you like

Origin blog.csdn.net/niyite/article/details/129966129