如何在HTML和CSS中绘制固定尺寸矩形内的响应矩阵?

发布于 2025-02-02 05:53:08 字数 1433 浏览 5 评论 0原文

我可以在固定大小的整流器内绘制此类内部矩形,但它们没有响应。

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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test div dimension</title>
    <style>
        #main {
            width: 640px;
            height: 360px;
            border: 1px solid black;
        }

        #content {
            width: 100%;
        }

        #slide {
            border: 1px solid red;
            width: calc(640*0.75px);
            height: calc(360*0.75px);
            float: right;
        }

        #camera {
            border: 1px solid red;
            width: calc(640 * 0.25px);
            height: calc(360 * 0.25px);
            float: left;
        }
    </style>
</head>

<body>
    <div id="main">
        <div id="content">
            <div id="slide">
                Rectange 1
            </div>
            
            <div id="camera">
                Rectange 2
            </div>
        </div>
    </div>
</body>

</html>

如何在固定尺寸的矩形内创建这种响应式内部直流?

enter image description here

I can draw such inner rectanges inside fixed size rectange but these are not responsive.

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

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test div dimension</title>
    <style>
        #main {
            width: 640px;
            height: 360px;
            border: 1px solid black;
        }

        #content {
            width: 100%;
        }

        #slide {
            border: 1px solid red;
            width: calc(640*0.75px);
            height: calc(360*0.75px);
            float: right;
        }

        #camera {
            border: 1px solid red;
            width: calc(640 * 0.25px);
            height: calc(360 * 0.25px);
            float: left;
        }
    </style>
</head>

<body>
    <div id="main">
        <div id="content">
            <div id="slide">
                Rectange 1
            </div>
            
            <div id="camera">
                Rectange 2
            </div>
        </div>
    </div>
</body>

</html>

How can I create such responsive inner rectanlges inside fixed size rectangle?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

把昨日还给我 2025-02-09 05:53:08

高度:100%;#content中也需要

#content {
    width: 100%;
    height: 100%;
}

#slide {
    border: 1px solid red;
    width: 75%;
    height: 75%;
    float: right;
}

#camera {
    border: 1px solid red;
    width: 25%;
    height: 25%;
    float: left;
}

height: 100%; is also required in #content

#content {
    width: 100%;
    height: 100%;
}

#slide {
    border: 1px solid red;
    width: 75%;
    height: 75%;
    float: right;
}

#camera {
    border: 1px solid red;
    width: 25%;
    height: 25%;
    float: left;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文