css - 实现 3 个图像精确大小的 CSS

标签 css bootstrap-4

所以我无法将 3 张图片放在同一行中,This is what I need..

问题是,这些图片并不总是相同的,所以当我上传一张尺寸不同的图片时,所有东西都会移动。有什么建议可以实现这一点吗?谢谢

HTML:

           <div class="first-slot">
             <div class="masonry-box post-media">
               <img src="upload/'.$row['fotos'].'" alt="" class="img-fluid">
                 <div class="shadoweffect">
                   <div class="shadow-desc">
                    <div class="blog-meta">
                     <span class="bg-orange"><a href="category-01.php" title="">'.$row['categoria'].'</a></span>
                      <h4><a href="single.php?id='.$row['id'].'" title="">'.$row['titulo'].'</a></h4>
                     <small><a href="single.php?id='.$row['id'].'" title="">'.$row['fecha'].'</a></small>
                     <small><a href="single.php?id='.$row['id'].'" title="">'.$row['autor'].'</a></small>
                    </div>
                   </div>
                 </div>
             </div>
           </div>

CSS:

    .first-slot {
    float: left;
    width: 65%;
    height: 35%;
}

.last-slot,
.second-slot {
    float: left;
    width: 35%;
    height: 28%;
}

自举

    .img-fluid {
  max-width: 100%;
  height: auto;
}

最佳答案

我认为这会解决您的问题。您可以在代码中使用这些类名和 css。根据您的要求更改图像 src 位置。并根据需要更改 css 中的 margin 属性。 PS: 不要忘记在元素文件中包含 Bootstrap 链接

 .imgItem{

        display: inline-block;
        margin: 10px;
    }
    .imgContainer{
        display: flex;
    }


<div class="row">
      <div class="col imgContainer" >
            <div class="col imgItem">
                <img src="http://placehold.it/150x100" class="img-responsive 
                " alt="Responsive image" />
                </div>
           <div class="col imgItem">
                <img src="http://placehold.it/150x100" class="img-responsive 
                " alt="Responsive image" />
           </div>
           <div class="col imgItem">
                <img src="http://placehold.it/150x100" class="img-responsive 
                " alt="Responsive image" />
           </div>
       </div>
    </div>

关于css - 实现 3 个图像精确大小的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59348781/

相关文章:

javascript - `background-size: cover;` 的 CSS 打印修复

html - 如何在左 :-20px;? 之后加宽 .li 右边缘

html - 如何使用 bootstrap4 将 CSS 应用于特定的 div 按钮?

html - 请教我如何将php的数据列表按4向右排序

html - 卡片内的响应表

html - 如何在 bootstrap 中将 div 推到行尾?

css - IonIcons 删除间距

html - 如何显示内容和侧边栏?

css - 如何避免 bootstrap 3 导航栏折叠成两行

javascript - 如何更改文本区域中闪烁的光标/插入符号