刷新後文本和圖像高度不匹配 - 一切正常。 謝謝你的幫助!文本和圖像高度不匹配
$(document).ready(function() {
$(window).resize(function() {
processPost();
});
function processPost() {
$('.post').each(function(i, e) {
$image = $(e).children('.post-image'),
$data = $(e).children('.post-data');
$image.css({
'background-image': isExist($image.attr('image-url')),
'height': $data.height(),
});
});
}
processPost();
function isExist(data) {
return `url(${ (data !== undefined && data !== '') ? data : '/data/no-photo.jpg' })`;
}
});
.post {
display: table;
margin: 4% 2%;
padding: .6em 1em;
background-color: #fefefe;
border-radius: 2px;
}
.post-cell, .post-image, .post-data {
display: inline-table;
}
.post-cell {
width: 100%;
}
.post-cell h4, .post-cell p {
margin: 0;
padding: .2em 0;
}
.post-cell h4 {
font-size: 1.5em;
}
.post-cell p {
color: #d7d7d7;
}
.post-image {
float: left;
width: 39%;
background-size: cover;
background-position: center;
border-radius: 2px;
min-height: 100px;
max-height: 300px;
}
.post-data {
padding-left: 2%;
width: 59%;
}
.post-data p {
margin: 0;
}
.text-right {
text-align: right !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="post">
<div class="post-cell">
<h4>Heading</h4>
</div>
<div class="post-image" image-url="http://www.openarium.ru/фото/грузия/тбилиси/дикие-горы-тушети.jpg">
</div>
<div class="post-data">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
<div class="post-cell text-right">
<p>meta, tag, metatag, meta-tag</p>
</div>
</div>
截圖: [圖片高度:175px,郵政高度:200像素]
歡迎來到StackOverflow,你的問題應該包含一個[**最小,完整和可驗證的例子**](http://stackoverflow.com/help/mcve)。 – hungerstar
你的文本容器有恆定的寬度嗎?你可以爲此粘貼css嗎? – Joint
一些CSS會很好 –