我正在尝试将p标签垂直对齐到图像的底部。我尝试了表格方法,因此文本div与图像div具有相同的高度,并且p标签与文本div的底部对齐。 div共享相同的高度,但文本div中的p标签不会与底部对齐。我究竟做错了什么?
HTML
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" href="main.css">
<title>V align testing</title>
</head>
<body>
<div class="container">
<div class="image">
<img src="55a4nzg3kpm01.jpg">
</div>
<div class="text">
<h1>Image title</h1>
<p>Text that should align bottom </p>
</div>
</div>
</body>
CSS
.container {
width: 1200px;
margin: 0 auto;
display: table;
height: 100%;
}
.image, .text{
width: 48%;
margin: 1%;
float: left;
display: table-cell;
height: 100%;
}
img {
width: 100%;
}
h1 {
text-transform: uppercase;
}
.text p {
display: inline-block;
vertical-align: bottom;
}