嗨,我的页面要有一个导航栏,然后在其下面有一个带有背景图像的标题,然后在其下面是主要内容。我遇到的问题是,当我将文本放在标题部分的背景图片上时,我无法正确配置它以进行响应。 Fiddle
<style>
header {
background:
linear-gradient(
rgba(0, 0, 0, 0.5),
rgba(0, 0, 0, 0.5)
),
url('http://getwallpapers.com/wallpaper/full/6/3/b/920866-download-free-beautiful-background-pics-1920x1200-for-ios.jpg');
background-size: cover;
height: 75vh;
}
</style>
<header>
<div class="topnav">
<a class="active" href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
</div>
<div class='headertext'>
<h1> Trying To Get This Text Responsive </h1>
</div>
</header>
<main>
Main Content Goes Here
</main>
style.css
/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}
/* Add a color to the active/current link */
.topnav a.active {
background-color: #4CAF50;
color: white;
}
最佳答案
h1默认情况下向左对齐。托盘:
使它居中
关于html - 无法获得文本响应并无法居中显示背景图片部分,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51292627/