我希望将标题文本移到图片上方。将图片的底边距更改为-50%有所帮助,但是根据屏幕大小,文本会显着移动。
.banner{
height: auto;
width: 100%;
max-width: 1200px;
z-index: 1;
text-align: right;
color: white;
margin: none;
bottom margin: none;
}
.title h1{
color: red;
width: 100%;
height:100%;
margin: auto;
z-index: 1;
text-align: center;
text-shadow: black;
float:left;
}
.title p{
color: red;
text-align: center;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<title>Joe's Garage</title>
<link rel="stylesheet" type="text/css" href="Garage CSS">
</head>
<body>
<div class="banner">
<img src="https://static1.squarespace.com/static/562837d1e4b0c53c5afbc078/t/5863246febbd1ab7ab5125b6/1482892406200/slide_405344_5057908_free.jpg?format=1500w">
</div>
<div class="title">
<h1>JOE'S GARAGE</h1>
<p>We Take the Worry Out of Car Trouble by Delivering Accurate Repairs at an Honest Price</p>
</div>
</body>
</html>