【问题标题】:lossing text with meta viewport使用元视口丢失文本
【发布时间】:2020-05-12 04:34:46
【问题描述】:

我正在创建我的第一个博客并且我正在尝试使其具有响应性,我使用元视口但是当我在不同大小的窗口中使用 Google Chrome 测试它时,我写的文本消失了。 这是我用 css 和 html 编写的一些代码,显示了我的问题:

.hero{
    background-color: firebrick;
    display: flex;
    justify-content: center;
}

.container{
    display: flex;
    justify-content: center;
    width: 1000px;
    padding: 10px;
}
<!DOCTYPE html>
<html>
<head>
    <title>test</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <link rel="stylesheet" href="C:/Users/MSI/Documents/programacion/html_y_css/estilos_test.css">
    <meta name="viewport" content="width=device-width, initial-scape=1.0">

</head>
<body>
    <section class="hero">
        <div class="container">
            <article>
                <h1> ¿quien soy?</h1>
                    <p> araragi koyomi: estudiante de bioingeniería . amante de la naturaleza; me gustan
                        las plantas y los animales en general, amo las matemáticas, me siento cómodo en lugares silenciosos y disfruto de ver anime,
                        salir con amigos, el queso, el vino y el chocolate, me encanta la programación y planeo enfocar mi carrera en programación 
                        tanto como pueda.
            </article>
            <figure>
                <img class="image-item" src="C:\Users\MSI\Documents\programacion\html_y_css\imagenes\viajes\yo_laguna.jpg" alt="no se encuentra una imagen" width="400px">
                <small> Figura: viaje a la laguna del otún</small>
            </figure>
        </div>

    </section>
</body>
</html>
我尝试使用属性 max-width 解决它,但窗口中显示的内容还包括正文,有人知道如何解决这个问题吗?谢谢你。 Stackoverflow 不允许我上传图片。

【问题讨论】:

    标签: html css web frontend responsive


    【解决方案1】:

    这是因为您使用的是确定的宽度。您的宽度设置为 1000 像素,这是固定的,这意味着无论设备使用什么,元素都只会跨越 1000 像素。要解决此问题,您可以使用百分比(使元素符合相对于其父元素的特定宽度)或使用查看器宽度(定义元素相对于用户屏幕或视口的宽度)。这是两种方式的方法:

    百分比:

    .container{
        display: flex;
        justify-content: center;
        width: 100%;
        padding: 10px;
    }
    

    查看器宽度:

    .container{
        display: flex;
        justify-content: center;
        width: 100vw;
        padding: 10px;
    }
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2011-09-13
      • 2017-09-11
      • 2016-08-08
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多