Cac*_*oon 3 css twitter-bootstrap angular-material2 angular
通常这不是问题,但是只有Material 2的Atm文档数量很少,因此我无法使所有图像具有相同的大小,但是可以通过更改窗口来正确调整大小
我当时创建的所有图像的大小都非常相似,但是在高度上要长一些,但是我的旧代码只是通过一些bootstrap调用进行了调整。
但是在垫层卡中使用图像时,图像的长度较长,因此看起来与此处显示的位置不符:
BAC计算器的图像比其余图像更长,因此看起来不适当,将其他图像推到不适当的位置,或者强制一个空单元格,这是我要求显示的图像:
<div *ngIf="data;else other_content">
<div class="row">
<div *ngFor="let project of data" class="col-md-6">
<div>
<mat-card class="mat-elevation-z4">
<mat-card-header>
<div mat-card-avatar class="example-header-image"></div>
<mat-card-title>{{project.title}}</mat-card-title>
<mat-card-subtitle>{{project.category}}</mat-card-subtitle>
<div class="grow-empty"></div>
<div *ngIf="project.source">
<button mat-raised-button (click)="openSite(project.source)">SOURCE</button>
</div>
</mat-card-header>
<img mat-card-image src="{{project.image}}" alt="{{project.title}}">
<mat-card-content>
<p>
{{project.detail | slice:0:250}}...
</p>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button>Information</button>
</mat-card-actions>
</mat-card>
</div>
<br>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我将高度设置为“ 300”之类的静态值,从技术上讲它可以解决问题,但重新缩放只会破坏它
我希望它是固定的比例,但是要拍摄任何图像并放大/缩小它以坐下,并使其适合卡本身的大小(例如Callum.Tech卡)
小智 6
只需在您的代码中添加此样式引用即可。如果要将此样式应用于视图中的所有卡片,请添加到样式文件中:
mat-card img{
object-fit: cover; /*this makes the image in src fit to the size specified below*/
width: 100%; /* Here you can use wherever you want to specify the width and also the height of the <img>*/
height: 80%;
}
Run Code Online (Sandbox Code Playgroud)
此问题的另一种解决方案可能是使用引导程序“ img响应”类。这是一个简短的描述
| 归档时间: |
|
| 查看次数: |
16636 次 |
| 最近记录: |