AngularJS Material 具有弹性布局重叠的卡片
AngularJS Material cards with flex layout overlap
我有一个页面有一些 AngularJS Material 卡片需要排列成两列。最后一张卡片应以全宽显示在两列下方。但是,卡片 #3 和 #4(取决于宽度)与最后一张卡片重叠。我花了几个小时调试它,但就是找不到为什么会这样。
这是我的代码:
angular.module('app', ['ngMaterial']).controller('ctrl', function() {});
<!-- Angular Material Stylesheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.css">
<!-- Angular Material requires Angular.js Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.5.9/angular-locale_de-de.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-route.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-messages.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-cookies.min.js"></script>
<!-- Angular Material Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.js"></script>
<div ng-app="app" ng-controller="ctrl" ng-cloak>
<form name="couponform" novalidate>
<div layout="column" layout-gt-sm="row">
<div flex="auto" flex-gt-sm="60">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #1</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #2</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #3</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #4</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
<div flex="auto" flex-gt-sm="40">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card right</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
</div>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card below</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>This should be below everything else</p>
</md-card-content>
<md-card-actions layout="row" layout-align="end center">
<md-button ng-click="submit()">Buchen</md-button>
</md-card-actions>
</md-card>
</form>
</div>
这里是输出的相关部分:
实际上,如果您 运行 此处的代码会按预期出现,但如果它是一个单独的 HTML 文件,则不会。很奇怪。
我已经为该代码段创建了 this codepen,即使将宽度更改为任何内容,它似乎也能正常工作。
这可能是浏览器问题,看起来不像是 Angular material 错误。
angular.module('app', ['ngMaterial']).controller('ctrl', function() {});
<!-- Angular Material Stylesheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.css">
<!-- Angular Material requires Angular.js Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.5.9/angular-locale_de-de.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-route.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-messages.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-cookies.min.js"></script>
<!-- Angular Material Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.js"></script>
<div ng-app="app" ng-controller="ctrl" ng-cloak>
<form name="couponform" novalidate>
<div layout="column" layout-gt-sm="row">
<div flex="auto" flex-gt-sm="60">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #1</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #2</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #3</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #4</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
<div flex="auto" flex-gt-sm="40">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card right</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
</div>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card below</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>This should be below everything else</p>
</md-card-content>
<md-card-actions layout="row" layout-align="end center">
<md-button ng-click="submit()">Buchen</md-button>
</md-card-actions>
</md-card>
</form>
</div>
您缺少 <!DOCTYPE html>
,否则浏览器将以怪癖模式呈现页面。
见Why do I need a doctype? (What does it do)
我有一个页面有一些 AngularJS Material 卡片需要排列成两列。最后一张卡片应以全宽显示在两列下方。但是,卡片 #3 和 #4(取决于宽度)与最后一张卡片重叠。我花了几个小时调试它,但就是找不到为什么会这样。
这是我的代码:
angular.module('app', ['ngMaterial']).controller('ctrl', function() {});
<!-- Angular Material Stylesheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.css">
<!-- Angular Material requires Angular.js Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.5.9/angular-locale_de-de.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-route.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-messages.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-cookies.min.js"></script>
<!-- Angular Material Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.js"></script>
<div ng-app="app" ng-controller="ctrl" ng-cloak>
<form name="couponform" novalidate>
<div layout="column" layout-gt-sm="row">
<div flex="auto" flex-gt-sm="60">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #1</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #2</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #3</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #4</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
<div flex="auto" flex-gt-sm="40">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card right</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
</div>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card below</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>This should be below everything else</p>
</md-card-content>
<md-card-actions layout="row" layout-align="end center">
<md-button ng-click="submit()">Buchen</md-button>
</md-card-actions>
</md-card>
</form>
</div>
这里是输出的相关部分:
实际上,如果您 运行 此处的代码会按预期出现,但如果它是一个单独的 HTML 文件,则不会。很奇怪。
我已经为该代码段创建了 this codepen,即使将宽度更改为任何内容,它似乎也能正常工作。
这可能是浏览器问题,看起来不像是 Angular material 错误。
angular.module('app', ['ngMaterial']).controller('ctrl', function() {});
<!-- Angular Material Stylesheet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.css">
<!-- Angular Material requires Angular.js Libraries -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-i18n/1.5.9/angular-locale_de-de.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-route.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-animate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-aria.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-messages.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-sanitize.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.9/angular-cookies.min.js"></script>
<!-- Angular Material Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/1.1.1/angular-material.min.js"></script>
<div ng-app="app" ng-controller="ctrl" ng-cloak>
<form name="couponform" novalidate>
<div layout="column" layout-gt-sm="row">
<div flex="auto" flex-gt-sm="60">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #1</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #2</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #3</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card left #4</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
<div flex="auto" flex-gt-sm="40">
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card right</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
<p>Some content</p>
</md-card-content>
</md-card>
</div>
</div>
<md-card>
<md-card-title>
<md-card-title-text>
<span class="md-headline">Card below</span>
</md-card-title-text>
</md-card-title>
<md-card-content>
<p>This should be below everything else</p>
</md-card-content>
<md-card-actions layout="row" layout-align="end center">
<md-button ng-click="submit()">Buchen</md-button>
</md-card-actions>
</md-card>
</form>
</div>
您缺少 <!DOCTYPE html>
,否则浏览器将以怪癖模式呈现页面。
见Why do I need a doctype? (What does it do)