Example analysis of using CSS to reduce images to equal proportions without deformation

黄舟
Release: 2017-09-30 09:28:32
Original
2873 people have browsed it




<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>CSS实现图片等比例缩小不变形</title>
        <link rel="stylesheet" type="text/css" href="../css/reset.css" />
    </head>
    <style type="text/css">
        .wrap {
            width: 90%;
            height: 550px;
            border: 1px solid #000;
            margin: 50px auto;
        }
        ul {
            width: 100%;
            height: 100%;
        }
        ul li {
            overflow: hidden;
            float: left;
            width: 350px;
            height: 350px;
            border: 1px solid #aaa;
            margin: 90px 0 0 43px;
        }
        ul li img {
            /*等宽缩小不变形*/
            /*width: 100%;*/
            /*二选一*/
            /*等高缩小不变形*/
            height: 100%;
        }
    </style>
    <body>
        <p class="wrap">
            <ul>
                <li>
                    <img src="../images/bg1.jpg" alt="" />
                </li>
                <li>
                    <img src="../images/bg2.jpg" alt="" />
                </li>
                <li>
                    <img src="../images/bg3.jpg" alt="" />
                </li>
            </ul>
        </p>
    </body>
</html>
Copy after login

The above is the detailed content of Example analysis of using CSS to reduce images to equal proportions without deformation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!