简体   繁体   English

MDL中的自适应CSS高度

[英]Adaptative CSS height in MDL

I have a website based on MDL, and I have a big header, in the center. 我有一个基于MDL的网站,并且在中心有一个很大的标题。 I put a box behind, to see the text. 我在后面放了一个盒子,看一下文字。

Here is the CodePen . 这是CodePen

The goal, is when people resize the window, such as mobile, the box get resized at the text height. 目的是当人们调整窗口大小(例如移动设备)时,框会在文本高度处调整大小。

How can we do this? 我们应该怎么做?

This is my CSS; 这是我的CSS;

.non-logged-in> .title-header-back {
        position: fixed;
        height: 100px;
        padding: 16px;
        background: rgba(0, 0, 0, 0.2);
}
.title-header {
        color: #fff;
}

And my HTML 还有我的HTML

<main class="mdl-layout__content mdl-typography--text-center">
    <div class="non-logged-in">
    <div class="title-header-back">
           <h1 class="non-logged-in title-header">Un bus à votre image</h1>
    </div>
    </div>
</main>

Thanks 谢谢

与其将固定高度设置为100px,不如将其设置为min-height:100px

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

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