在正常的窗口大小下,我的網站包含標題照片,在照片上寫有歡迎和旅行建議,並位於標題底部的導航欄。我希望它在手機視圖中看起來一樣,但每次我最小化屏幕和導航欄移動到頁面頂部,其餘的正文內容隨後移動時,寫入和標題照片消失。其他一切正常。我只是試圖找到一種方法來保持移動視圖中的標題照片和它下面的導航欄。謝謝!屏幕最小化時,頁眉照片(上方導航欄)消失
我的HTML代碼:
<style>
.brand,
.address-bar {
text-align: center;
background: url("img/photo.jpg") no-repeat center center fixed;
background-size: cover;
position: relative;
top: -10%;
left: -10%;
right: -10%;
min-width: 110%;
min-height: -10%;
padding: 100px;
font-size: 50px;
color: black;
margin-top:-1%;
}
......
@media screen and (min-width:768px) {
.brand {
display: inherit;
margin: 0;
text-align: right;
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
font-family: "Josefin Slab", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 5em;
font-weight: 700;
line-height: normal;
color: #fff;
}
.address-bar {
display: inherit;
margin: 0;
padding: 0 150px 400px;
text-align: right;
text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
text-transform: uppercase;
font-size: 1.25em;
font-weight: 400;
letter-spacing: 3px;
color: #fff;
}
......
</style>
.....
<body>
<div class="brand"> Welcome </div>
<div class="address-bar"> Travel recommendations </div>
<!-- Navigation -->
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
...
非常感謝!有效。問題是我沒有頭標籤內的照片類。 – rhodocoder