사용자가 피드에 콘텐츠를 게시 할 모바일 앱을 만들고 있습니다. 각 게시물에 대해 콘텐츠와 그림을 추가 할 수있는 별도의 div 영역이 있습니다. 문제는 동일한 div에 모조 문서와 사진을 모두 붙여 넣을 때 높이가 떨어져 자체 조정이되지 않는다는 것입니다.콘텐츠를 추가 할 때 div 높이를 자동으로 조정하는 방법은 무엇입니까?
로 설정하면 완전히 덮여 회색 배경 영역을 가지고 내가 자동으로 높이를 설정할 때 지금 모습입니다. 회색 배경 영역이 짧게 절단되어 있습니다.
목표는 사용자가 추가하는 내용에도 불구하고 높이 자동 조정에 사업부 영역입니다. 나는 height:auto
, height:auto !important
, height: 100%
, height:100 !important
및 overflow:hidden
을 시도했다. 그 중 누구도 내게 원하는 결과를주지 못했습니다. 회색 배경 영역이 모든 것을 자동으로 처리하도록하는 가장 좋은 방법은 무엇입니까? JavaScript 또는 jQuery를 사용하여 답변을 수락합니다.
HTML
<!-- Feed Begins -->
<section class="feed section-padding">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="FalconsFan1 text-center">
<p>FalconsFan1</p>
</div>
<div class="-posts text-center">
<p>497 posts</p>
</div>
<!-- Posts -->
<div class="container Second-Post">
<div class="row">
<div class="col-sm-12">
<img src="img/bitmap_2.jpg" alt="" class="post-avatar">
<h4 class='post-username'>FalconFans1</h4>
<small class="post-timestamp">32 seconds ago</small>
<p class='post-content'>Julio is the best receiver in the game right now!</p>
<img src="img/post-img.jpg" alt="" class="post-img">
<ul class="polling-icons text-center">
<li><img src="img/green-like-button.png" alt=""></li>
<li><img src="img/grey-dislike-button.png" alt=""></li>
<li><img src="img/grey-comment-button.png" alt=""></li>
</ul>
</div>
</div>
</div>
<!-- Posts -->
</div>
</div>
</div>
</section>
CSS만큼 당신이 스타일 시트의 모든 일에 position:absolute
이없는
.feed {
margin-top: -50% !important;
}
.FalconsFan1 {
/* width: 392px;
height: 78px; */
font-size: 64px;
letter-spacing: 0.7px;
text-align: center;
color: #3f3f3f;
margin-left: -15%;
}
.-posts {
/* width: 208px;
height: 49px; */
font-size: 40px;
letter-spacing: 0.5px;
text-align: center;
color: #3f3f3f;
margin-left: -15%;
}
.Second-Post {
object-fit: contain;
background-color: #f8f8f8;
height: auto;
width: 988px !important;
}
.Second-Post::after {
content: " ";
display: block;
clear: both;
}
.post-avatar {
position: absolute;
margin-top: 1%;
left: 5%;
width: 86px;
height: 88px;
}
.post-username {
position: absolute;
left: 20%;
font-size: 42px;
}
.post-timestamp {
position: absolute;
margin-top: 6%;
left: 20.5%;
}
.post-content {
position: absolute;
margin-top: 10%;
left: 20.5%;
width: 754px;
height: 70px;
font-size: 27px;
letter-spacing: 0.8px;
color: #3f3f3f;
}
.post-img {
position: absolute;
margin-top: 17%;
left: 20.5%;
width: 779px;
height: 588px;
}
.polling-icons {
list-style: none;
position: absolute;
margin-top: 80%;
left: 10%;
}
.polling-icons li {
padding: 0;
display: inline !important;
padding: 130px;
}
문제는 JS가 해결해야 할 필요가 없다. 절대적인 위치이거나 유동 문서에서 img를 만들 수 있어야한다. 아마 img에 대한 스타일을 표시 할 수 있을까? 'class = "post-img"'? – DaniP
'post-img' 클래스에 CSS를 추가 할 수 있습니까? –
게시물이 업데이트되었습니다 –