我有一些元素将包含一个固定大小的图像和一些可变长度的文本,一个令人讨厌的行为我注意到当文本大于文本容器高度div元素增长但不压下显示的元素波纹管(身体有方向列的柔性显示),这是最好的结果吗?
这就是我所说的:https://imgur.com/a/MjwOxXX
注意上部是如何从下部通过重叠而不是整个容器生长并向下部区域向下移动来占据空间。
这是我的代码:
body{display:flex; flex-direction:column; height:auto; font-family:Roboto Slab; position:relative; scroll-bahaviour:smooth;}
*{box-sizing:border-box; margin:0; padding:0;}
a{text-decoration:none;}
.squared_maincontainer{width:100%; height:auto; display:flex; flex-direction:column;}
.squared_title{width:100%; height:100px; display:flex; justify-content:center; align-items:center; font-size:37px; font-weight:500; color:rgba(0,0,0,0.8);}
.squared_contents_container{width:100%; height:auto; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap;}
.squared_content_container{width:32%; height:auto; display:flex; flex-direction:column; margin:10px 0px;}
.squared_content_image{width:100%; height:260px; outline:1px solid rgba(0, 0, 0, 0.3); background-repeat:no-repeat; background-size:cover;}
.squared_content_texts_container{width:100%; height:145px; display:flex; flex-direction:column; padding:10px; position:relative;}
.squared_content_texts_title{ width:100%; font-weight:500; font-size:17px; color:var(--main_color); margin-bottom:10px;}
.squared_content_texts_description{width:100%; height:auto; font-weight:500; oveflow:hidden; font-size:14px; color:rgba(0, 0, 0, 0.9); margin-bottom:10px;}
.squared_content_texts_link{width:100%; font-size:14px; color:var(--main_color); font-weight:400; text-align:right; marin-top:auto;}
.menu_maincontainer{width:100%; height:auto; display:flex; flex-direction:column;}
.menu_title{width:100%; height:100px; display:flex; justify-content:center; align-items:center; font-size:37px; font-weight:500; color:rgba(0,0,0,0.8);}
.menu_contents_container{width:100%; height:auto; display:flex; justify-content:space-around; flex-wrap:wrap;}
.menu_content_image_container{width:32%; height:280px; box-shadow:3px 3px 3px rgba(0,0,0,0.1); background-size:cover; position:relative; }
.menu_content_texts_container{width:100%; height:auto; position:absolute; bottom:0px; left:0px; background-color:rgba(0,0,0,0.7); display:flex; flex-direction:column; padding:10px;}
.menu_content_texts_title{font-size:18px; font-weight:400; color:var(--main_color);}
.menu_content_texts_description{font-size:15px; font-weight:400; color:white;}
<div class="squared_maincontainer push" style="">
<span class="squared_title" style="">Eventos</span>
<div class="squared_contents_container" style="">
<a href="" class="squared_content_container" style="">
<div class="squared_content_image" style="background-image:url('img/dogs22.jpg');"></div>
<div class="squared_content_texts_container" style=" ">
<span class="squared_content_texts_title" style="">When our dog is afraid of men</span>
<span class="squared_content_texts_description" style="">One common dog fear is that of men — but is it normal and can it be fixed? We look at the causes and solutions for when Man’s Best FriendOne common dog fear is that of men — but is it normal and can it be fixed? We look at the causes and solutions for when Man’s Best Friend doesn’t live upOne common dog fear is that of men — but is it normal and can it be fixed?One common dog fear is that of men — but is it normal and can it be fixed? We look at the causes and solutions for when Man’s Best FriendOne common dog fear is that of men — but is it normal and can it be fixed? We look at the causes and solutions for when Man’s Best Friend doesn’t live upOne common dog fear is that of men — but is it normal and can it be fixed? We look at the causes and solutions for when Man’s Best Friend doesn’t live up to...</span>
<span class="squared_content_texts_link" style="">Read More</span>
</div>
</a>
<a href="" class="squared_content_container" style="">
<div class="squared_content_image" style="background-image:url('img/dogs12.jpg');"></div>
<div class="squared_content_texts_container" style=" ">
<span class="squared_content_texts_title" style="">When our dog is afraid of men</span>
<span class="squared_content_texts_description" style="">One common dog fear is that of men — but is it normal and can it be fixed? We look at the causes and solutions for when Man’s Best Friend doesn’t live up to...</span>
<span class="squared_content_texts_link" style="">Read More</span>
</div>
</a>
<a href="" class="squared_content_container" style="">
<div class="squared_content_image" style="background-image:url('img/dogs2.jpg');"></div>
<div class="squared_content_texts_container" style="">
<span class="squared_content_texts_title" style="">When our dog is afraid of men</span>
<span class="squared_content_texts_description" style="">One common dog fear is that of men — but is it normal and can it be fixed? We look at the causes and solutions for when Man’s Best Friend doesn’t live up to...</span>
<span class="squared_content_texts_link" style="">Read More</span>
</div>
</a>
</div>
</div>
<div class="menu_maincontainer push" style="">
<a class="menu_title" href="" style="">Título de sección</a>
<div class="menu_contents_container" style="">
<div class="menu_content_image_container" style="background-image:url('img/dogs32.jpg');">
<div class="menu_content_texts_container" style="">
<a class="menu_content_texts_title" href="" style="">Titulo</a>
<a class="menu_content_texts_description" href="" style="">Descripción del titulo</a>
</div>
</div>
<div class="menu_content_image_container" style="background-image:url('img/dogs30.jpg');">
<div class="menu_content_texts_container" style="">
<a class="menu_content_texts_title" href="" style="">Titulo</a>
<a class="menu_content_texts_description" href="" style="">Descripción del titulo</a>
</div>
</div>
<div class="menu_content_image_container" style="background-image:url('img/dogs22.jpg');">
<div class="menu_content_texts_container" style="">
<a class="menu_content_texts_title" href="" style="">Titulo</a>
<a class="menu_content_texts_description" href="" style="">Descripción del titulo</a>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
我已经查看了你的代码,我注意到.squared_content_texts_container类将描述文本高度修复为145px。这就是为什么当第一个盒子的高度增加时,它没有调整父div的高度。
尝试从.squared_content_texts_container类中删除145px高度,或者将 min - 高度设置为145px。
然后,三个柔性盒将在中间垂直对齐,但如果您希望它们顶部对齐,则必须使用align-self:flex-start;在.squared_content_container类上设置样式。
请查看此jsFiddle的结果。 https://jsfiddle.net/katerynas/d3n5ksps/
$post->tags->pluck('name')