CSS:底部居中 bootstrap 分页元素
CSS: Bottom-Centering a bootstrap pagination element
好的,所以我有一个使用嵌入式视图的 angular 应用程序。不确定这是否重要,但我将所有嵌入替换为正常 html 文件时的实际外观。无论如何,我试图在我的页面底部水平居中固定的 uib-pagination 元素。
<!DOCTYPE html>
<html>
<head>
<title></title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- Imports for my personal stylesheet as well as ui-bootstrap's and angular material's stylesheets go here-->
</head>
<body style="width:100vw; height:auto">
<div ng-app="app" layout-fill ng-cloak>
<div class="root-container" layout-fill style="width:100vw; height:auto padding:0; position: absolute;">
<md-content layout="column" layout-fill style="width:100vw; height:auto">
<md-toolbar style="width:100vw; height:auto">
<div class="md-toolbar-tools">
<md-button aria-label="Go Back"> Go Back </md-button>
<md-button class="md-raised" aria-label="Learn More"> Learn More </md-button>
</div>
</md-toolbar>
<md-tabs md-selected="vm.selectedIndex" md-border-bottom>
<md-tab label="Home"> </md-tab>
<md-tab label="Submit"> </md-tab>
<md-tab label="Contact"> </md-tab>
</md-tabs>
<md-content class="main-body-content">
<ul uib-pagination total-items="vm.itemCount" items-per-page="vm.itemsPerPage" ng-model="vm.currentPage" ng-change="log()" max-size="vm.maxShownPagination" class="pagination-lg" boundary-links="true" force-ellipses="true">
</ul>
</md-content>
</div>
</md-content>
</div>
</div>
<!---- scripts go here ---->
</body>
</html>
这是我的样式表,其中主体内容的背景为红色以增强对比度和查看能力:
.main-body-content {
height: 100vh;
width: 100vw;
background: red;
}
.pagination-lg {
position: fixed;
bottom: 0px;
width: 100vw;
margin-left: auto;
margin-right: auto;
}
下面是截图:
如您所见,分页元素位于页面底部附近,它确实会随着视口滚动,但它不是水平居中的。帮助? CSS.
的新手
如果您正在使用 Angular material,您可以使用以下库进行分页,基于 Material 设计
https://github.com/Crawlink/material-angular-paging
它会与 Angular material 样式相得益彰,而不是使用具有完全不同样式的 Angular Bootstrap。
下面的代码片段摘自他们的 Github 页面。分页元素已经水平对齐。
var app = angular.module("DemoApp", ['ngMaterial', 'cl.paging']);
app.controller("MainController", ['$scope', function($scope) {
$scope.currentPage = 0;
$scope.paging = {
total: 100,
current: 1,
onPageChanged: loadPages,
};
function loadPages() {
console.log('Current page is : ' + $scope.paging.current);
// TODO : Load current page Data here
$scope.currentPage = $scope.paging.current;
}
}]);
<!doctype html>
<html ng-app="DemoApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
<script src="https://cdn.gitcdn.link/cdn/angular/bower-material/v1.1.0-rc.5/angular-material.js"></script>
<script src="https://rawgit.com/Crawlink/material-angular-paging/master/build/dist.min.js"></script>
<script src="example.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
</head>
<body>
<div ng-controller="MainController" flex layout="column">
<section flex>
<md-content layout-padding="">
<h1>Material Angular Paging demo</h1>
<div>Loaded data form Page <strong>{{currentPage}}</strong></div>
</md-content>
</section>
<section layout="row" layout-padding="">
<cl-paging flex cl-pages="paging.total" , cl-steps="6" , cl-page-changed="paging.onPageChanged()" , cl-align="center center" , cl-current-page="paging.current"></cl-paging>
</section>
</div>
</div>
</body>
</html>
好的,所以我有一个使用嵌入式视图的 angular 应用程序。不确定这是否重要,但我将所有嵌入替换为正常 html 文件时的实际外观。无论如何,我试图在我的页面底部水平居中固定的 uib-pagination 元素。
<!DOCTYPE html>
<html>
<head>
<title></title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- Imports for my personal stylesheet as well as ui-bootstrap's and angular material's stylesheets go here-->
</head>
<body style="width:100vw; height:auto">
<div ng-app="app" layout-fill ng-cloak>
<div class="root-container" layout-fill style="width:100vw; height:auto padding:0; position: absolute;">
<md-content layout="column" layout-fill style="width:100vw; height:auto">
<md-toolbar style="width:100vw; height:auto">
<div class="md-toolbar-tools">
<md-button aria-label="Go Back"> Go Back </md-button>
<md-button class="md-raised" aria-label="Learn More"> Learn More </md-button>
</div>
</md-toolbar>
<md-tabs md-selected="vm.selectedIndex" md-border-bottom>
<md-tab label="Home"> </md-tab>
<md-tab label="Submit"> </md-tab>
<md-tab label="Contact"> </md-tab>
</md-tabs>
<md-content class="main-body-content">
<ul uib-pagination total-items="vm.itemCount" items-per-page="vm.itemsPerPage" ng-model="vm.currentPage" ng-change="log()" max-size="vm.maxShownPagination" class="pagination-lg" boundary-links="true" force-ellipses="true">
</ul>
</md-content>
</div>
</md-content>
</div>
</div>
<!---- scripts go here ---->
</body>
</html>
这是我的样式表,其中主体内容的背景为红色以增强对比度和查看能力:
.main-body-content {
height: 100vh;
width: 100vw;
background: red;
}
.pagination-lg {
position: fixed;
bottom: 0px;
width: 100vw;
margin-left: auto;
margin-right: auto;
}
下面是截图:
如您所见,分页元素位于页面底部附近,它确实会随着视口滚动,但它不是水平居中的。帮助? CSS.
的新手如果您正在使用 Angular material,您可以使用以下库进行分页,基于 Material 设计
https://github.com/Crawlink/material-angular-paging
它会与 Angular material 样式相得益彰,而不是使用具有完全不同样式的 Angular Bootstrap。
下面的代码片段摘自他们的 Github 页面。分页元素已经水平对齐。
var app = angular.module("DemoApp", ['ngMaterial', 'cl.paging']);
app.controller("MainController", ['$scope', function($scope) {
$scope.currentPage = 0;
$scope.paging = {
total: 100,
current: 1,
onPageChanged: loadPages,
};
function loadPages() {
console.log('Current page is : ' + $scope.paging.current);
// TODO : Load current page Data here
$scope.currentPage = $scope.paging.current;
}
}]);
<!doctype html>
<html ng-app="DemoApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
<script src="https://cdn.gitcdn.link/cdn/angular/bower-material/v1.1.0-rc.5/angular-material.js"></script>
<script src="https://rawgit.com/Crawlink/material-angular-paging/master/build/dist.min.js"></script>
<script src="example.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.css">
</head>
<body>
<div ng-controller="MainController" flex layout="column">
<section flex>
<md-content layout-padding="">
<h1>Material Angular Paging demo</h1>
<div>Loaded data form Page <strong>{{currentPage}}</strong></div>
</md-content>
</section>
<section layout="row" layout-padding="">
<cl-paging flex cl-pages="paging.total" , cl-steps="6" , cl-page-changed="paging.onPageChanged()" , cl-align="center center" , cl-current-page="paging.current"></cl-paging>
</section>
</div>
</div>
</body>
</html>