【问题标题】:Adding Image to Bootstrap card-body mobile responsive problem将图像添加到 Bootstrap 卡体移动响应问题
【发布时间】:2021-10-07 21:10:55
【问题描述】:

我有一张底部有图片的bootstrap 卡片。我的代码还使用 AngularJS 和 ASP.net 。

当页面变得足够小时,图像会从卡体中移出(向左移动)。

无论屏幕尺寸如何,我都希望图像保持在同一个位置。

示例:

我拥有和想要保留的东西:

The image of the wished outcome in every screen size

特定屏幕尺寸后的结果:

Image of the actual outcome

代码: 我将代码的哪一部分作为注释添加了问题

    <div class="Title text-info"> {{man.GroupName}} </div>

    <div class="row">
        <div class="col-sm-6 col-md-6 col-lg-4 col-xl-3 mb-3 mh-100" ng-repeat="m in man.Items">

            <div class="card bg-dark shadow-sm" style="height:250px;">from a file
                <a class="card-body e-bg-cover" style="background-image: url('../../Content/Image/BackGrounds/doc_bg_{{manuals.indexOf(man)%4+1}}B.jpg');">  //Get different images from a file
                    <h4 class="font-weight-bold">{{m.Name}} <span ng-if="m.NewDocument" class="text-warning float-right">@Page.New</span> </h4> //Gets text from a resx file, Yes, it is ASP 

                    <p class="text-white-50">{{m.Description}}</p>


                    // problematic piece of code:
                        <a ng-href="{{m.FileRoute}}">
                            <img src="~/Content/Image/Logos/e_pdf.png" target="_blank" class="e_Manuals_pdf" />
                        </a>
                
                   

                </a>

            </div>
        </div>

    </div>
</div>

CSS 以防万一:

 .e_Manuals_pdf {
        position: absolute;
        top: 170px; 
        right: 280px; 
        z-index: 1;

        width: 45px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;    }



.e-bg-cover {
  background-size: cover; }




.Title {
  display: inline-block;
  width: 100%;
  font-size: 24px;
  margin: 0 auto 10px auto;
  font-weight: bold;
  padding: 5px 0px;
  border-bottom: #1CA8DD solid 1px; }
  .eniacTitle .eniacBtn {
    font-size: 14px;
    font-weight: normal; }
    .eniacTitle .eniacBtn a {
      height: 50px;
      line-height: 45px; }
    .eniacTitle .eniacBtn i {
      font-size: 30px;
      margin: 0; }

【问题讨论】:

    标签: html css asp.net angularjs bootstrap-4


    【解决方案1】:
    .card {
        position: relative; /*To fix the PDF IMG*/
    }
    
    .e_Manuals_pdf {
        position: absolute;
        bottom: 15px;
        left: 15px;
        z-index: 1;
        width: 45px;
     
        object-fit: contain; /*To fix the PDF size*/
    
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    

    谢谢你Nikkkshit

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-10
      • 2016-10-09
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多