简体   繁体   English

根据视口宽度缩放容器的全部内容

[英]Scaling the entirely content of a container based on the viewport width

I'm trying to get the following up with a text inside a container: Desired behavior animation我正在尝试使用容器内的文本进行后续操作: Desired behavior animation

But unfortunately, that's what I'm getting: My approach但不幸的是,这就是我得到的:我的方法

Here's the code I have so far:这是我到目前为止的代码:

<!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">
    <style>
        .container {
            max-width: 1920px;
            margin: 0 auto;
        }

        .title {
            font-size: clamp(12px, 10vw, 142px);
            text-transform: uppercase;
            align-items: center;
            white-space: nowrap;
            width: 100%;
        }
        .title:last-child{
            text-align: right;
        }
    </style>
</head>

<body>
    <section>
        <div class="container">
            <h2 class="title">Get in touch</h2>
            <h2 class="title">Know about me</h2>
        </div>
    </section>
</body>
</html>

You should set height of your container using vw as well as width of your element consider您应该使用vw设置容器的高度以及考虑元素的宽度

height : 20vw;

It will work as you want, let me know if otherwise它会按你想要的那样工作,否则请告诉我

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM