css - 如何在分页中的移动 View 中显示更少的页面?

标签 css reactjs pagination material-ui

问题

需要在移动 View 中显示较少的页面,以便它可以与同一行中的标题(我的订单)对齐。

enter image description here

图书馆

material-ui/pagination

进展

能够删除移动 View 中的NextPrevious 内容,但既不能找到任何现成的 prop(s) 也不能找到任何 CSS 来减少移动 View 中的页面数

WebView

enter image description here

移动 View

enter image description here

代码

CSS

@media (min-width: 501px) {
.MuiPagination-root {
.MuiPagination-ul {
    flex-wrap: nowrap;
    li {
        &:first-child {
            flex-basis: 100%;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            > button::before {
                margin-right: 10px;
                content: "Previous  ";
            }
        }
        &:last-child {
            flex-basis: 100%;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            > button::after {
                margin-left: 10px;
                margin-right: 20px;
                content: "  Next";
            }
        }
    }
}
}

自定义组件

    import React, { useState } from "react";
    import PropTypes from "prop-types";
    import Pagination from '@material-ui/lab/Pagination';

    export const CustomPagination = ({ onChange, totalRecords, currentPage, className, shape }) => {
        return (
            <Pagination
                count={totalRecords}
                shape={shape}
                className={className}
                onChange={onChange}
                page={currentPage}
            />
        )
    };

    CustomPagination.propTypes = {
        paginationLength: PropTypes.number,
        selectPage: PropTypes.func,
        activePage: PropTypes.number,
    };

最佳答案

我想出的解决方案之一是将组件分页包装在一个 Box 中,然后根据 View 更改其大小:

export function Test() {
  return;
  <>
    <Box sx={{ display: { xs: "none", md: "block" } }}>
      <Pagination
      />
    </Box>
    <Box sx={{ display: { xs: "block", md: "none" } }}>
      <Pagination
        size="small"
      />
    </Box>
  </>;
}
        </Box>

关于css - 如何在分页中的移动 View 中显示更少的页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66459115/

相关文章:

html - 未知级别 ul 中最后一个 ul 的 Css 选择器

html - Bootstrap Navbar 元素未正确对齐

javascript - React-Material-ui : Autocomplete on words that aren't the first in a sentence

java - 通过分页写入 Jena RDF 模型

javascript - 进度条描边颜色

javascript - 构造函数 vs componentWillMount;什么是 componentWillMount 可以做而构造函数不能做的?

javascript - Reactjs 获取身份验证和访问 token ,无法解析响应

c# - 如何在asp gridview中使用分页模板进行自定义分页?

seo - 如何使用 robots.txt 阻止机器人抓取分页?

html - 无法在页面上看到我的表单按钮或页脚