组件分页_如何创建分页组件

组件分页

The theme for week #17 of the Weekly Coding Challenge is:

每周编码挑战第17周的主题是:

分页 (Pagination)

A Pagination Component is used on websites where you have more content available than you want to display at one time to the user so you'd split it on multiple pages. By separating the content on different pages you are also saving a lot of bandwidth for the user because it won't be required to download all the information at once.

分页组件用于网站上,您所拥有的内容比一次要向用户显示的内容要多,因此您可以将其拆分为多个页面。 通过分隔不同页面上的内容,您还为用户节省了大量带宽,因为不需要一次下载所有信息。

Some examples where you'd have a pagination: a blog with multiple pages, an online store with multiple products, etc.

您可以进行分页的一些示例 :具有多个页面的博客,具有多种产品的在线商店等。

In this article we're going to build this Pagination Component:

在本文中,我们将构建此分页组件 :

Note: the pagination is not functional, it's just for demo purposes (the visual). As an extra challenge, you can link this on a real website.

注意 :分页功能不起作用,仅用于演示目的(视觉效果)。 作为额外的挑战,您可以在一个真实的网站上链接它。

HTML (The HTML)

For the HTML structure we're going to use an ul as a wrapper with multiple lis. Each li will have an a tag within it because it's clickable (and semantic) and it'll send the user to the required page (if needed).

对于HTML结构,我们将使用ul作为带有多个li的包装器。 每个li都将在其中包含a标签,因为它是可单击的(和语义),并且会将用户定向到所需的页面(如果需要)。

We're also using FontAwesome for the icons (left, right and the dots icons).

我们还将FontAwesome用于图标(左侧,右侧和圆点图标)。

<ul class="pagination"><li><a href="#"><i class="fas fa-chevron-left"></i></a></li><li><a href="#"><i class="fas fa-ellipsis-h"></i></a></li><li><a href="#">2</a></li><li class="active"><a href="#">3</a></li><li><a href="#">4</a></li><li><a href="#">5</a></li><li><a href="#"><i class="fas fa-ellipsis-h"></i></a></li><li><a href="#"><i class="fas fa-chevron-right"></i></a></li>
</ul>

As you can see I also added an .active class to one of the lis - this is just to highlight the page we are on.

正如你可以看到我还增加了.active类的一个li秒-这仅仅是重点突出一页,我们都在。

CSS (The CSS)

I'm going to paste the CSS and we'll discuss the important pieces afterwards.

我将粘贴CSS,然后我们将讨论重要的部分。

.pagination {border: 2px solid #aaa;border-radius: 4px;display: flex;list-style-type: none;overflow: hidden;padding: 0;
}.pagination li {background-color: #fff;
}.pagination li:hover,
.pagination li.active {background-color: #aaa;
}.pagination li a {color: #555;display: block;font-weight: bold;padding: 10px 15px;text-decoration: none;
}.pagination li:hover a,
.pagination li.active a {color: #fff;
}

Things to note:

注意事项:

  1. The ul / .pagination it's a flex container - this is because it's much easier to position the lis within it by using flexbox (and who doesn't like flexbox? ?)

    ul / .pagination是一个flex容器-这是因为使用flexbox将li放置在其中很容易(而且谁不喜欢flexbox ??)

  2. Because we have a little bit of a border-radius on the ul we need to add overflow: hidden because otherwise the li's corner will be visible on top of the border of the ul (remove the overflow and you'll see what I mean)

    因为我们在ul上有一个小border-radius ,所以我们需要添加overflow: hidden因为否则, li的角将在ul的边界上可见(去除溢出,您将看到我意思)

  3. We have the same styling on li:hover as on li.active, but you can differentiate between these to states if you want

    我们在li:hover上的样式与在li.active上的样式相同,但是您可以根据需要在状态之间进行区分

Other than that, I believe it's pretty straightforward, but if you have any questions please let me know. ?

除此之外,我相信这非常简单,但是如果您有任何疑问,请告诉我。 ?

结论 (Conclusion)

There are other variants of paginations out there on the web. Find one you like and convert it to code.

网络上还有其他分页方式。 找到您喜欢的一个并将其转换为代码。

Make sure you share with me what you've built!

确保您与我分享您的作品!

Happy Coding! ?

编码愉快! ?

翻译自: https://www.freecodecamp.org/news/how-to-create-a-pagination-component/

组件分页

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391204.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

web-项目管理

总结 目的是 1.可查询 2.方便团队管理 每个成员都可以看到任何东西 项目 需求 计划 bug 按模板来 1.问题描述 2.原因分析 3.解决方法 开发 提交代码 按模板来 1.问题描述 2.原因分析 3.解决方法 打包 更新说明文件.txt 按模板来 一、更新说明 1.问题描述 1&#xff09;计划号 2…

cnn对网络数据预处理_CNN中的数据预处理和网络构建

cnn对网络数据预处理In this article, we will go through the end-to-end pipeline of training convolution neural networks, i.e. organizing the data into directories, preprocessing, data augmentation, model building, etc.在本文中&#xff0c;我们将遍历训练卷积神…

leetcode 554. 砖墙

你的面前有一堵矩形的、由 n 行砖块组成的砖墙。这些砖块高度相同&#xff08;也就是一个单位高&#xff09;但是宽度不同。每一行砖块的宽度之和应该相等。 你现在要画一条 自顶向下 的、穿过 最少 砖块的垂线。如果你画的线只是从砖块的边缘经过&#xff0c;就不算穿过这块砖…

django-rest-framework解析请求参数过程详解

https://www.jb51.net/article/165699.htm 转载于:https://www.cnblogs.com/gcgc/p/11544187.html

递归 和 迭代 斐波那契数列

#include "stdio.h"int Fbi(int i) /* 斐波那契的递归函数 */ { if( i < 2 ) return i 0 ? 0 : 1; return Fbi(i - 1) Fbi(i - 2); /* 这里Fbi就是函数自己&#xff0c;等于在调用自己 */ }int main() { int i; int a[40]; printf("迭代显示斐波那契数列…

单元测试 python_Python单元测试简介

单元测试 pythonYou just finished writing a piece of code and you are wondering what to do. Will you submit a pull request and have your teammates review the code? Or will you manually test the code? 您刚刚编写了一段代码&#xff0c;并且想知道该怎么做。 您…

飞行模式的开启和关闭

2019独角兽企业重金招聘Python工程师标准>>> if(Settings.System.getString(getActivity().getContentResolver(),Settings.Global.AIRPLANE_MODE_ON).equals("0")) { Settings.System.putInt(getActivity().getContentResolver(),Settings.Global.AIRPLA…

消解原理推理_什么是推理统计中的Z检验及其工作原理?

消解原理推理I Feel:我觉得&#xff1a; The more you analyze the data the more enlightened, data engineer you will become.您对数据的分析越多&#xff0c;您将变得越发开明。 In data engineering, you will always find an instance where you need to establish whet…

pytest+allure测试框架搭建

https://blog.csdn.net/wust_lh/article/details/86685912 https://www.jianshu.com/p/9673b2aeb0d3 定制化展示数据 https://blog.csdn.net/qw943571775/article/details/99634577 环境说明&#xff1a; jdk 1.8 python 3.5.3 allure-commandline 2.13.0 文档及下载地址&…

lintcode433 岛屿的个数

岛屿的个数 给一个01矩阵&#xff0c;求不同的岛屿的个数。 0代表海&#xff0c;1代表岛&#xff0c;如果两个1相邻&#xff0c;那么这两个1属于同一个岛。我们只考虑上下左右为相邻。 您在真实的面试中是否遇到过这个题&#xff1f; Yes样例 在矩阵&#xff1a; [[1, 1, 0, …

大数据分析要学习什么_为什么要学习数据分析

大数据分析要学习什么The opportunity to leverage insights from data has never been greater.利用来自数据的洞察力的机会从未如此大。 Humans tend to generate a lot of data each day - from heart rates to favorite songs, fitness goals and movie preferences. You …

POJ - 3257 Cow Roller Coaster (背包)

题目大意&#xff1a;要用N种材料建一条长为L的路&#xff0c;如今给出每种材料的长度w。起始地点x。发费c和耐久度f 问&#xff1a;在预算为B的情况下&#xff0c;建好这条路的最大耐久度是多少 解题思路&#xff1a;背包问题 dp[i][j]表示起始地点为i。发费为j的最大耐久度…

leetcode 1473. 粉刷房子 III(dp)

在一个小城市里&#xff0c;有 m 个房子排成一排&#xff0c;你需要给每个房子涂上 n 种颜色之一&#xff08;颜色编号为 1 到 n &#xff09;。有的房子去年夏天已经涂过颜色了&#xff0c;所以这些房子不需要被重新涂色。 我们将连续相同颜色尽可能多的房子称为一个街区。&a…

大学生信息安全_给大学生的信息

大学生信息安全You’re an undergraduate. Either you’re graduating soon (like me) or you’re in the process of getting your first college degree. The process is not easy and I can only assume how difficult the pressures on Masters and Ph.D. students are. Ho…

打破冷漠僵局文章_保持冷静并打破僵局-最佳

打破冷漠僵局文章Hack The Box (HTB) is an online platform allowing you to test your penetration testing skills. It contains several challenges that are constantly updated. Some of them simulating real world scenarios and some of them leaning more towards a …

使用DOM Breakpoints找到修改属性的Javascript代码

使用Chrome开发者工具的DOM断点功能可以让您快速找到修改了某一个DOM元素的Javascript代码。 在Chrome开发者工具里&#xff0c;选中想要监控的DOM元素&#xff0c;点击右键&#xff0c;选择Break on->Attributes modifications: 之后在DOM Breakpoints的tab里能看到对应的断…

特斯拉最安全的车_特斯拉现在是最受欢迎的租车选择

特斯拉最安全的车Have you been curious to know which cars are most popular in US and what are their typical rental fares in various cities? As the head of Product and Data Science at an emerging technology start-up, Ving Rides, these were some of the quest…

leetcode 740. 删除并获得点数(dp)

给你一个整数数组 nums &#xff0c;你可以对它进行一些操作。 每次操作中&#xff0c;选择任意一个 nums[i] &#xff0c;删除它并获得 nums[i] 的点数。之后&#xff0c;你必须删除每个等于 nums[i] - 1 或 nums[i] 1 的元素。 开始你拥有 0 个点数。返回你能通过这些操作…

WebSocket入门

WebSocket前言  WebSocket是HTML5的重要特性&#xff0c;它实现了基于浏览器的远程socket&#xff0c;它使浏览器和服务器可以进行全双工通信&#xff0c;许多浏览器&#xff08;Firefox、Google Chrome和Safari&#xff09;都已对此做了支持。 在WebSocket出现之前&#xff…

安卓游戏开发推箱子_保持冷静并砍箱子-开发

安卓游戏开发推箱子Hack The Box (HTB) is an online platform allowing you to test your penetration testing skills. It contains several challenges that are constantly updated. Some of them simulating real world scenarios and some of them leaning more towards …