英文:
CSS Page Pagination Style
问题
以下是翻译好的内容:
CSS 样式概述
我正在尝试设计一个 CSS 样式,其中左侧包括客户部分,右侧包括选定的客户详细信息,并在底部放置分页按钮。您可以参考图片以进行可视化。
尝试实现的目标
我的目标是在客户容器内启用滚动,以便内容可以根据需要扩展。但是,我希望分页按钮始终可见,即使滚动时也保持在页面底部。请给我一个实现这种布局的想法。
使用 Chakra UI 与 Next.js。
import { Flex, Heading, Input, InputGroup, Stack, Text, Avatar, Box, Center, Divider } from "@chakra-ui/react";
import ContentHeader from "./design/ContentHeader";
import WhiteButton from "./design/WhiteButton";
export default function Customers() {
return (
<Flex width="100%" flexDir="column" gap="1rem" height="100%">
<ContentHeader description="" heading="Total Customers (50)" />
<Flex gap="0.1rem">
<CustomersList />
<Flex flex={1} bg="var(--grey-color)" rounded="lg" height={'auto'} justifyContent={'center'}>
<Flex py = {'2rem'} flexDir={'column'} alignContent={'center'} gap={'1rem'}>
<Center>
<Avatar size="xl" name="Kent Dodds" src="link" />
</Center>
<Center flexDir={'column'}>
<Heading fontSize={'xl'}>Kent C Dodds</Heading>
<Text fontSize={'sm'}>Owner at Corsa Auto Rentals</Text>
</Center>
<Divider color={'white'}/>
<Center flexDir={'column'}>
<Heading fontSize={'xl'}>Email Address</Heading>
<Text fontSize={'md'}>ethan@ethanduran.com</Text>
</Center>
<Center gap={'1rem'} flexWrap={'wrap'}>
<WhiteButton>Message</WhiteButton>
<WhiteButton>Edit</WhiteButton>
<WhiteButton>Documents</WhiteButton>
</Center>
</Flex>
</Flex>
</Flex>
{/*pagination bar*/}
<WhiteButton>pagination button 1</WhiteButton>
<WhiteButton>pagination button 2</WhiteButton>
</Flex>
);
}
const CustomersList = () => {
return (
<Flex flex={3} width={'100%'}>
<Stack spacing={4} padding="1rem" width={'100%'} maxH={'100%'}>
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
</Stack>
</Flex>
);
}
const CustomerData = ({ }) => {
return (
<Flex
background="var(--grey-color)"
padding="1rem"
gap="1.5rem"
flexDir="row"
rounded="lg"
overflowX="auto"
>
<Avatar size="md" name="Kent Dodds" src="link" />
<Stack spacing={0}>
<Text fontSize="lg" whiteSpace="nowrap">
Kent C Dodds
</Text>
<Text fontSize="xs" whiteSpace="nowrap">
+92 311 628****
</Text>
</Stack>
<Flex gap="1rem" marginLeft="auto">
{["Vehicles", "Payments", "Referrals"].map((title, idx) => {
return (
<Stack key={idx} spacing={0} textAlign="center">
<Text fontWeight="bold">{title}</Text>
<Text fontWeight="bold">20</Text>
</Stack>
);
})}
</Flex>
</Flex>
);
}
英文:
CSS Style Overview
I'm attempting to design a CSS style that includes a customer section on the left side, the selected customer details on the right side, and pagination buttons at the bottom. You can refer to the image for visualization.
Try to achive
>My goal is to enable scrolling within the customer container so that the content can expand as needed. However, I want the pagination buttons to always remain visible beneath the customer container, even when scrolling, and stay at the bottom of the page. please give me an idea how can i achive this kind of layout.
===========================
= | u =
= | s =
= N Customers | e =
= | r =
= pagination Buttons | =
===========================
Using chakra ui with next-js.
import { Flex, Heading, Input, InputGroup, Stack, Text, Avatar, Box, Center, Divider } from "@chakra-ui/react";
import ContentHeader from "./design/ContentHeader";
import WhiteButton from "./design/WhiteButton";
export default function Customers() {
return (
<Flex width="100%" flexDir="column" gap="1rem" height="100%">
<ContentHeader description="" heading="Total Customers (50)" />
<Flex gap="0.1rem">
<CustomersList />
<Flex flex={1} bg="var(--grey-color)" rounded="lg" height={'auto'} justifyContent={'center'}>
<Flex py = {'2rem'} flexDir={'column'} alignContent={'center'} gap={'1rem'}>
<Center>
<Avatar size="xl" name="Kent Dodds" src="link" />
</Center>
<Center flexDir={'column'}>
<Heading fontSize={'xl'}>Kent C Dodds</Heading>
<Text fontSize={'sm'}>Owner at Corsa Auto Rentals</Text>
</Center>
<Divider color={'white'}/>
<Center flexDir={'column'}>
<Heading fontSize={'xl'}>Email Address</Heading>
<Text fontSize={'md'}>ethan@ethanduran.com</Text>
</Center>
<Center gap={'1rem'} flexWrap={'wrap'}>
<WhiteButton>Message</WhiteButton>
<WhiteButton>Edit</WhiteButton>
<WhiteButton>Documents</WhiteButton>
</Center>
</Flex>
</Flex>
</Flex>
{/*pagination bar*/}
<WhiteButton>pagination button 1</WhiteButton>
<WhiteButton>pagination button 2</WhiteButton>
</Flex>
);
}
const CustomersList = () => {
return (
<Flex flex={3} width={'100%'}>
<Stack spacing={4} padding="1rem" width={'100%'} maxH={'100%'}>
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
<CustomerData />
</Stack>
</Flex>
);
}
const CustomerData = ({ }) => {
return (
<Flex
background="var(--grey-color)"
padding="1rem"
gap="1.5rem"
flexDir="row"
rounded="lg"
overflowX="auto"
>
<Avatar size="md" name="Kent Dodds" src="link" />
<Stack spacing={0}>
<Text fontSize="lg" whiteSpace="nowrap">
Kent C Dodds
</Text>
<Text fontSize="xs" whiteSpace="nowrap">
+92 311 628****
</Text>
</Stack>
<Flex gap="1rem" marginLeft="auto">
{["Vehicles", "Payments", "Referrals"].map((title, idx) => {
return (
<Stack key={idx} spacing={0} textAlign="center">
<Text fontWeight="bold">{title}</Text>
<Text fontWeight="bold">20</Text>
</Stack>
);
})}
</Flex>
</Flex>
);
}
答案1
得分: 1
在您分享的代码中,无法获取分页组件。
但是可以通过将 display: flex; flex-direction: column;
应用于包裹 <List />
和 <Pagination/>
组件的包装器 div(例如 .list)来实现此目的。
如果列表有时可能较小,并且您希望分页栏始终位于页面底部,请将 flex:grow: 1;
添加到包装器 div(.list)中的 <List />
和 <Pagination />
。
查看我创建的类似结构的 JSFiddle,其中包括列表较小的情况: https://jsfiddle.net/4zqvny5f/2/
英文:
In Your shared code, could not get the pagination component.
However this can be achived by applying display: flex; flex-direction: column;
to the wrapper div (say .list) of <List />
and <Pagination/>
component.
And if the list can be smaller sometimes and you want the pagination bar to always be at the bottom of the page, add flex:grow: 1;
to the wrapper div (.list) of <List />
and <Pagination />
Checkout the similar structured JSFiddle I created. Including the case when list is small: https://jsfiddle.net/4zqvny5f/2/
答案2
得分: 0
解决你的问题的是CSS中的position: fixed;
。假设你的分页栏是div.bar
,请添加以下CSS规则集:
div.bar {
position: fixed;
bottom: 0;
height: 20px;
left: 100px;
right: 100px;
}
当然,这只是一个概念验证/示例,你可以根据需要更改这些值。
英文:
What solves your problem is the position: fixed;
in CSS.
Supposing that your pagination bar is div.bar
, add to it the following CSS ruleset:
div.bar {
position: fixed;
bottom: 0;
height: 20px;
left: 100px;
right: 100px;
}
For sure this is just a Proof of Concept / example, and you can change the values as you want.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论