gpt4 book ai didi

javascript - 100% 高度响应式标题

转载 作者:行者123 更新时间:2023-11-28 05:24:44 26 4
gpt4 key购买 nike

我的标题有一些问题,但找不到解决方案。我需要将标题显示为 100% 窗口屏幕。我必须制作 100% 高度响应式标题,当有人想要调整大小以获得更小的视口(viewport)时,它不应该在标题下方显示任何内容。内部 header 是带有 bootstrap carousel 的嵌套 div。这是我的代码。

http://codepen.io/anon/pen/EgJmEj

https://jsfiddle.net/3oht91fg/

<body>

<header>
<div class="container">
<div class="logo">
<a href="index.html">
</a>
</div>
</div>

<nav>
<div class="container">
<ul class="nav-bar">
<li><a class="active-subpage" href="">Option test</a></li><!--
--><li><a href="">Option test</a></li><!--
--><li><a href="">Option test</a></li><!--
--><li><a href="">Option test</a></li><!--
--><li><a href="">Option test</a></li><!--
--><li><a href="">Option test</a></li></ul>
</div>
</nav>

<div class="slider">

<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="" contenteditable="false"></li>
<li data-target="#myCarousel" data-slide-to="1" class="active" contenteditable="false"></li>
<li data-target="#myCarousel" data-slide-to="2" class="" contenteditable="false"></li>
</ol>
<div class="carousel-inner">
<div class="item" style="">
<img src="http://placehold.it/1920x1080">

<div class="carousel-caption">
<h4 class="">First Slide Title</h4>
<p class="">
Description for First Slide, this First Slide.
</p>
</div>
</div>
<div class="item active">
<img src="http://placehold.it/1920x1080">
<div class="carousel-caption">
<h4 class="">Second Slide Title</h4>

<p class="">
Description for Second Slide, this is Second Slide.
</p>
</div>
</div>
<div class="item" style="">
<img src="http://placehold.it/1920x1080">
<div class="carousel-caption">
<h4 class="">Third Slide Title</h4>

<p class="">
Description for Third Slide, this is Third Slide.
</p>
</div>
</div>
</div>

<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>

<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>


</div>

</div>



</header>
<main>

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a euismod libero. Phasellus elementum rutrum sapien et facilisis. Curabitur finibus eros laoreet ligula faucibus, quis interdum mauris efficitur. Aenean posuere iaculis sem, vitae pulvinar nibh aliquam dignissim. Nulla quis tristique dui. Duis luctus semper dignissim. Aenean tellus tellus, interdum at egestas nec, elementum ut tortor. Integer sodales nisi quam, ut rhoncus odio scelerisque ut. Morbi interdum leo a velit tempus sagittis.Integer nec pharetra sapien. In vel imperdiet leo. Phasellus at sagittis odio. Cras eu placerat ex. Aliquam scelerisque placerat felis at porttitor. Donec accumsan fringilla tincidunt. Vivamus rhoncus enim id fermentum pulvinar. Pellentesque orci ipsum, egestas a pellentesque nec, porttitor vitae diam. Nam sodales condimentum ligula a gravida. Duis cursus, risus a posuere suscipit, nunc ex sagittis risus, non ullamcorper purus ipsum vitae elit. Phasellus ac pharetra diam, eget efficitur nulla. Duis a convallis ligula. Maecenas sit amet tempor neque, nec mollis leo. Vivamus turpis nisl, dignissim iaculis vehicula eu, consectetur non augue.Etiam dictum porta imperdiet. Curabitur ut nisl eget odio tristique aliquam. Sed vel vestibulum mi. Etiam lacinia justo nec lorem aliquet, tincidunt venenatis orci consectetur. Proin venenatis hendrerit velit, in porttitor purus ullamcorper eget. Fusce justo orci, porta ac auctor id, sagittis eget ipsum. Donec sodales metus eget est efficitur consequat. Integer congue massa mi, at molestie ex feugiat ut. Nam ac sem justo. Vestibulum euismod non dolor nec pretium. Aenean pretium magna et nisi scelerisque tempus. Vestibulum mollis eleifend mauris, vehicula pellentesque diam condimentum nec. Aliquam id justo tristique, ultricies erat quis, malesuada ligula. Sed justo tortor, auctor non ultrices a, congue in urna. Curabitur lacinia magna lectus, in aliquet nunc imperdiet sodales.Quisque quis lorem tellus. Praesent volutpat pretium ligula, sit amet tempor ipsum pharetra in. Proin pellentesque finibus quam, vel ultricies est viverra eget. Aliquam nec consequat turpis. Suspendisse et augue leo. Maecenas rhoncus felis sit amet ipsum lobortis elementum. Quisque fermentum metus vel felis ornare aliquam. Mauris tempor mauris nisl, in pellentesque est euismod sit amet. Nunc fringilla leo non dolor imperdiet sollicitudin. Sed vulputate volutpat bibendum. Nunc quis molestie quam. Sed nec ultricies neque, eget ultrices urna.Quisque tristique risus non egestas iaculis. Nunc porta non eros sit amet luctus. Nam pellentesque dolor nec dolor semper ultricies. Etiam euismod lectus in augue volutpat, a mollis ipsum dapibus. Praesent nulla eros, luctus a viverra ut, consequat et eros. Nulla dignissim ligula eget elit sollicitudin faucibus. In non tempus leo. Suspendisse pulvinar eros et eros elementum, eget luctus ex ullamcorper. Cras elementum, lectus tristique facilisis lacinia, dolor nibh tempor tortor, eget pharetra nibh nisl eget quam. Suspendisse aliquam tempus pharetra. Sed cursus risus quis orci laoreet dapibus.
</p>

</main>

<footer>
<div class="container">
<div class="left-footer col-md-4">
<p>&copy; TEST</p>
</div>

<div class="right-footer col-md-8">

<p>MADE BY ADER</p>

</div>
</div>
</footer>

最佳答案

适用于 CSS3 兼容的浏览器。还有一种方法可以使用定位来实现此目的,但如果您的网站受众主要使用更新的浏览器,则标记量会超出必要的范围。

header {
height:100vh;
}

1vh = 垂直高度的 1%50vh = 50%100vh = 100%。

关于javascript - 100% 高度响应式标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40266058/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com