gpt4 book ai didi

html - 全高 div 对景观的响应

转载 作者:太空宇宙 更新时间:2023-11-04 01:43:34 25 4
gpt4 key购买 nike

我正在制作一个具有固定导航栏、全屏背景和中间文本的页面。而且我不知道如何让它在横向模式下响应。在其他版本上,它表现正常,但在横向上,因为我认为高度要小得多,所以文本与导航栏重叠。而且看起来真的很乱。

我可以在当前代码中更改一些内容来修复此问题但仍保留全屏 div 吗?我到处都看过,但没有任何效果。

到目前为止,这是我的代码:

.hero {
height: 100vh;
width: 100%;
background: url('http://lorempixel.com/1200/600/') no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: relative;
}

.headline {
position: absolute;
top: 50%;
left: 0%;
right: 0;
transform: translate(0%, -50%);
-webkit-transform: translate(0%, -50%);
}

.headline h2 {
font-weight: 100;
font-size: 48px;
color: #212121;
margin-bottom: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">

<div class="hero">
<nav class="navbar navbar-toggleable navbar-light bg-faded fixed-top">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>


<div class="headline text-center">
<div>
<h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br>Morbi in volutpat diam, ut laoreet magna. </h2>
<a class="btn btn-primary rounded-0" href="#">LINK ONE</a>
<a class="btn btn-secondary rounded-0" href="#" target="_blank">LINK TWO</a>
</div>
</div>
<!-- /.headline -->
</div>








<div style="height:900px"></div>

最佳答案

你可以使用媒体查询来设置css

对于实验:

<style  type="text/css">
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px)
and (orientation : landscape) {
/* STYLES GO HERE */
height: 50vh;
}
</style>

关于html - 全高 div 对景观的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44949411/

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