组件分页

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/

组件分页

组件分页_如何创建分页组件相关推荐

  1. 苹果设计组件库_建立设计系统和组件库

    苹果设计组件库 This post is based on the series of posts: Modernizing a jQuery frontend with React. If you ...

  2. java实现layui分页_基于LayUI分页和LayUI laypage分页的使用示例

    本文介绍了LayUI分页,LayUI动态分页,LayUI laypage分页,LayUI laypage刷新当前页,分享给大家,具体如下: 效果图: 一.引用js依赖 主要是jquery-1.11. ...

  3. java 组件化_(原创)搭建一个组件化的监控平台

    最近看到一位同事正在开发一个监控软件,要求就是通过针对服务器现有的一些接口,通过这些接口返回的数据进行分析,如果监控的值到达预先设定的范围则通过短信的方式发送给管理员. 从整个开发的功能上来看是一个比 ...

  4. swift 组件化_打造完备的iOS组件化方案:如何面向接口进行模块解耦?

    作者 | 黑超熊猫zuik,一个修行中的 iOS 开发,喜欢搞点别人没搞过的东西,钻研过逆向工程.VIPER 架构和组件化. 关于组件化的探讨已经有不少了,在之前的文章 iOS VIPER架构实践(三 ...

  5. java新闻分页_新闻实现分页显示

    一.数据显示:(大容量数据显示特点) 1.以列表方式显示数据的特点: 优势:数据能够按照指定格式显示,布局清晰,不受信息数量的限制 不足:当数据量较多,需要用户拖动页面才能浏览更多信息 当采用分页技术 ...

  6. 易语言mysql数据库分页_易语言分页读数据库 mysql数据库分页

    易语言读MySQL数据库出现中文乱码,求高手赐教? 看下mysql数据的编码, 再用易语言,使用同样的编码去链接mysql数据库 易语言如何读取数据库中固定行列的数据? 有几个命令:打开(),用于打开 ...

  7. React Table 表格组件使用教程 排序、分页、搜索过滤筛选功能实战开发

    React Table 表格组件使用教程 react-table 安装和使用 React Table 表格排序功能 React Table 表格搜索过滤筛选功能 React Table 表格分页功能 ...

  8. 《前端》Element ui 表格(Table)组件中前端实现数据分页和模糊查询--未看

    我是用的Element ui 表格(Table)组件中的例子 下面是别人自己写的方法: Element ui 表格(Table)组件中前端实现数据分页和模糊查询_明天也要努力的博客-CSDN博客  h ...

  9. react 组件样式_如何使用样式化组件为React组件创建视觉变体

    react 组件样式 by Gilad Dayagi 通过吉拉德·达亚吉 如何使用样式化组件为React组件创建视觉变体 (How to create visual variants for Reac ...

最新文章

  1. python csv模块心得
  2. 用koa mongodb 做了个简单的博客系统
  3. vscode+eslint自动格式化vue代码的方法
  4. springboot集成prometheus
  5. mysql sqlite 分页查询_php基于SQLite实现的分页功能示例
  6. matlab八个实验报告中文版,Matlab实验报告8
  7. 应用软件系统程序员的三个立面
  8. windows安装解压版mysql
  9. 【视频】LSTM神经网络架构和原理及其在Python中的预测应用|数据分享
  10. ListView的刷新
  11. 基于74hc573的数码管模块测试
  12. 小巷开店问题(答案揭晓)
  13. [luoguT30208]太极剑
  14. 使用JAVA对数据库的记录进行操作(初步)
  15. java计算机毕业设计响应式交友网站MyBatis+系统+LW文档+源码+调试部署
  16. 1750. 救生员 Lifeguards S
  17. stm32单片机实现多个闹钟_基于STM32F103系列单片机的11个定时器解析
  18. 连接tcp服务器出现的问题及解决方法
  19. 优雅的实现 Excel 导入导出
  20. java ffmpeg 合并视频_android ffmpeg视频剪切与合并

热门文章

  1. java支付模块架构,涨薪7K!
  2. MMKV集成与原理,轻松拿下offer
  3. django中的admin组件
  4. 【小摘抄】关于C++11下 string各类用法(持续更新)
  5. iOS https双向配置
  6. 利用find同时查找多种类型文件
  7. Android成长日记-Android监听事件的方法
  8. TechEd2009
  9. linux jenkins部署之路之,ftp部署怎么匿名还好用咋解决思密达
  10. 各种机器学习的优缺点及应用场景