我想將標題文本移動到圖片上。將圖片的底部邊距改爲-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>
你想在圖像中間的標題?您可以使用[flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)輕鬆完成此操作。 –
是的,我願意!我剛纔嘗試過,但沒有運氣。 – Ryan