gpt4 book ai didi

css - 正确对齐的 div 内的 Angular Material 卡必须具有相同的高度

转载 作者:太空宇宙 更新时间:2023-11-04 09:38:09 25 4
gpt4 key购买 nike

我的问题是我想以某种方式将卡片的高度设置为相等,这样无论卡片的文字有多长,其他文字较少的卡片都会拉伸(stretch)到与最大卡片相同的高度。我将 md-card 嵌套在重复的 div 中,因为我将 padding 设置为 div,然后 md-card 是分开的,它们之间有空格,就像我一样想。但高度不同。

另一种选择是删除 md-card 元素并将白框设置为重复的 div,但是我不会在白框框之间留出空间。

这是plunker url:http://plnkr.co/edit/NDdYvHhuvhTie2Sy9Mg5?p=preview

这是 html :

    <!DOCTYPE html>
<html lang="en" >
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Angular Material style sheet -->
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
<style>
.category-card md-card img{
width: 100%;
height:auto;
padding: 0;
}
.category-card md-card h3{
-webkit-margin-before: 5px;
-webkit-margin-after: 5px;
}
.category-card md-card p{
font-size: 1.1em;
word-wrap: break-word;
}
</style>

</head>
<body ng-app="BlankApp" ng-cloak>
<section layout-padding>
<div layout="row" layout-wrap class="category-wrapper">
<div flex-xl="25"
flex-lg="33"
flex-md="50"
flex-sm="50"
flex-xs="100"
layout-padding
class="category-card"
ng-repeat="category in [{text:'Heloooooooooooooooooooooooooooooo'},
{text:'Heloooooooooooooooooooooooooooooo'},
{text:'Heloooooooooooooooooooooooooooooo'},
{text:'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'}]">

<md-card ui-sref="....">
<img src="http://graywolfseo.com/wp-content/uploads/choosing-urls.jpg" class="md-card-image" alt="{{category.category_image_alt}}">
<md-card-title>
<md-card-title-text>
<h3 class="md-headline">TEXTTTTTTTTTTT</h3>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>
{{category.text}}
</p>
</md-card-content>
</md-card>
</div>
</div>
</section>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>

<!-- Angular Material Library -->
<script src="http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js"></script>

<!-- Your application bootstrap -->
<script type="text/javascript">
/**
* You must include the dependency on 'ngMaterial'
*/
angular.module('BlankApp', ['ngMaterial']);
</script>

</body>
</html>

最佳答案

我建议使用 md-grid-list 来解决这个问题 - Plunker

标记

  <md-grid-list
md-cols-xl="4"
md-cols-lg="3"
md-cols-md="2"
md-cols-sm="2"
md-cols-xs="1"
md-row-height="1:1"
md-gutter="20">
<md-grid-tile ng-repeat="category in [{text:'Heloooooooooooooooooooooooooooooo'},
{text:'Heloooooooooooooooooooooooooooooo'},
{text:'Heloooooooooooooooooooooooooooooo'},
{text:'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB'}]">
<md-card ui-sref="...." layout-fill>
<img src="http://graywolfseo.com/wp-content/uploads/choosing-urls.jpg" class="md-card-image" alt="{{category.category_image_alt}}">
<md-card-title>
<md-card-title-text>
<h3 class="md-headline">TEXTTTTTTTTTTT</h3>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>
{{category.text}}
</p>
</md-card-content>
</md-card>
</md-grid-tile>
</md-grid-list>

CSS

p {
word-break: break-all;
}

文档

https://material.angularjs.org/latest/api/directive/mdGridList https://material.angularjs.org/latest/api/directive/mdGridTile

演示

https://material.angularjs.org/latest/demo/gridList

关于css - 正确对齐的 div 内的 Angular Material 卡必须具有相同的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40148567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com