首页 > 解决方案 > 如何在css中缩小图像

问题描述

你好,我怎样才能通过 320 youtube 图标调整我的 320 大小 在此处输入图像描述

我希望它的大小像应用程序在桌面上看起来一样小但是我似乎无法做到这一点

.icons{
width: 30px;
height: 30px;
}

或者

<div class="icons">
    <img src="/img/youtube icon.png" width: 30px; height: 30px; alt="">
</div>

这是代码

这是 HTML 代码——(Ps 我已经删除了高度和宽度代码,因为它不起作用)

<!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">
    <link rel="stylesheet" href="/board.css">
    <title>Board</title>
</head>
<body>
    <div class="Board">
        <div class="panel">
            <div class="user">
                <h3>Good Morning, Admin!</h3>
            </div>
            <div class="icons">
                <img src="/img/youtube icon.png" alt="">
            </div>
        </div>
        <div class="right-panel">
        <div class="heading">

        </div>
        <div class="dashboard">

        </div>
    </div>
    </div>
</body>
</html>

这是 CSS 代码——

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@font-face{
    src: url(/fonts/Coiny-Regular.ttf);
    font-family: Coiny;
}

body, html{
    background-color: rgb(230, 230, 230);
    font-family: Arial, Helvetica, sans-serif;
}

.Board{
    display: flex;
    align-items: center;
    text-align: center;
    justify-content: left;
}

.panel{
    background-color: white;
    width: 450px;
    height: 650px;
    border-radius: 2rem;
    margin-left: 40px;
    margin-top: 30px;
    box-shadow: 7px 7px 7px 7px rgba(202, 202, 202, 0.3);
}

.right-panel{
    background-color: white;
    width: 950px;
    height: 650px;
    border-radius: 2rem;
    margin-left: 40px;
    margin-top: 30px;
    box-shadow: 7px 7px 7px 7px rgba(202, 202, 202, 0.3);
}

.user h3{
    background-color: whitesmoke;
    text-align: start;
    padding: 20px;
    font-size: 20px;
    border-radius: 2rem;
    font-family: Coiny, cursive;
    margin: 20px;
}

谢谢!

标签: htmlcss

解决方案


.icons以该类为目标元素,因此您可以这样做

<img src="/img/youtube icon.png" class="icons" alt="">

或将您的选择器更新为该类中的目标元素:

.icons img {
  width: 30px;
  height: 30px;
}

推荐阅读