1.布局-Overscroll Behavior

overscroll behavior 用于控制浏览器到达滚动区域边界时的行为的功能类。这个属性可以用来防止在有多个滚动区域的页面中出现不必要的滚动。

1.1 快速参考

Class Properties
overscroll-auto overscroll-behavior: auto;
overscroll-contain overscroll-behavior: contain;
overscroll-none overscroll-behavior: none;
overscroll-y-auto overscroll-behavior-y: auto;
overscroll-y-contain overscroll-behavior-y: contain;
overscroll-y-none overscroll-behavior-y: none;
overscroll-x-auto overscroll-behavior-x: auto;
overscroll-x-contain overscroll-behavior-x: contain;
overscroll-x-none overscroll-behavior-x: none;

1.2 基本用法

1.2.1 阻止父元素的过度滚动

overscroll-auto
说明:它用于将滚动行为设置为默认。即使到达元素的边界,整个页面也会连同元素一起滚动。它是默认值。

overscroll-contain
说明:用来设置滚动行为,只对所使用的元素进行默认。在元素到达边界后进一步滚动,不会滚动它后面的元素。在相邻的滚动区域不会发生滚动链。

<html lang="en"><head><link rel="stylesheet" href="../dist/output.css" /></head><body class="text-center"><h1 class="text-green-500 text-5xl font-bold">Tailwind CSS overscroll-behavior</h1><b>Tailwind CSS overscroll-auto and overscroll-contain Class</b><div class="flex"><divclass="bg-green-500 mx-24 p-4 w-1/3 h-16 overscroll-contain overflow-y-auto text-justify">Well, let me tell you something, funny boy. Y'know that little stamp, the one that says "NewYork Public Library"? Well that may not mean anything to you, but that means a lot to me.One whole hell of a lot.</div><div class="bg-pink-500 p-2 w-1/4 h-24 overscroll-auto overflow-y-auto">Sure, go ahead, laugh if you want to. I've seen your type before: Flashy, making the scene,flaunting convention. Yeah, I know what you're thinking. What's this guy making such a bigstink about old library books? Well, let me give you a hint, junior.</div></div><div class="h-[2000px]"></div></body>
</html>

  1. 左边的div元素设置了overscroll-contain,即使滚动到底,只要在这个元素滚动就不会影响父元素的滚动条。
  2. 右边的div元素设置overscroll-contain,滚动到底后,在这个元素里面滚动,父元素的滚动条也会跟着滚动

1.2.2 阻止过度滚动的反弹

暂时未发现这个属性的作用

以后发现了会补充

1.3 有条件的应用

1.3.1 悬停、焦点和其他状态

Tailwind 允许您使用变体修饰符在不同状态下有条件地应用效用类。例如,使用 仅在悬停时应用该实用程序。hover:overscroll-contain``overscroll-contain

<div class="overscroll-auto hover:overscroll-contain"><!-- ... -->
</div>

有关所有可用状态修饰符的完整列表,请查看 Hover、Focus 和 Other State 文档。

1.3.2 断点和媒体查询

您还可以使用变体修饰符来定位媒体查询,如响应式断点、深色模式、首选减少运动等。例如,用于仅在中等屏幕尺寸及以上位置应用该实用工具。md:overscroll-contain``overscroll-contain

<div class="overscroll-auto md:overscroll-contain"><!-- ... -->
</div>

若要了解详细信息,请查看有关响应式设计、深色模式和其他媒体查询修饰符的文档。

2.布局-Top/Right/Bottom/Left

2.1 快速参考

属性很多,请点击链接进入官网查看Top / Right / Bottom / Left - Tailwind CSS (wyz.xyz)

2.2 基本用法

2.2.1 放置定位元素

使用 {top|right|bottom|left|inset}-0 功能类,将绝对定位的元素锚定在最近定位的父元素的任何边缘上。

结合 Tailwind 的 padding 和 margin 功能类,您可能会发现这些是所有的您需要的用来精确控制绝对定位元素的功能类。

<html lang="en"><head><link rel="stylesheet" href="../dist/output.css" /></head><body class="text-center"><h1 class="text-green-500 text-5xl font-bold">Tailwind CSS Top/Right/Bottom/Left</h1><div class="flex w-72 sm:w-96 mx-auto justify-between flex-shrink-0 flex-wrap"><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute left-0 top-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">01</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute inset-x-0 top-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">02</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute top-0 right-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">03</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute inset-y-0 left-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">04</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute inset-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">05</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute inset-y-0 right-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">06</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute left-0 bottom-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">07</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute inset-x-0 bottom-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">08</div></div><div class="relative w-20 h-20 sm:w-28 sm:h-28 bg-purple-500 rounded-lg m-2"><divclass="absolute right-0 bottom-0 p-4 flex justify-center items-center text-white bg-purple-900 rounded-lg">09</div></div></div></body>
</html>

sm屏幕显示

其他情况:

2.2.2 使用负值

若要使用负上/右/下/左值,请在类名前面加上短划线前缀,以将其转换为负值。

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><link rel="stylesheet" href="../dist/output.css" /></head><body><div class="relative top-10 w-20 h-20 sm:w-28 sm:h-28 mx-auto bg-purple-500 rounded-lg"><div class="absolute -left-4 -top-4 p-8 bg-purple-900 rounded-lg"></div></div></body>
</html>

2.3 有条件的应用

2.3.1 悬停、焦点和其他状态

Tailwind 允许您使用变体修饰符在不同状态下有条件地应用效用类。例如,使用 仅在悬停时应用该实用程序。hover:top-6``top-6

<div class="top-4 hover:top-6"><!-- ... -->
</div>

有关所有可用状态修饰符的完整列表,请查看 Hover、Focus 和 Other State 文档。

2.3.2 断点和媒体查询

您还可以使用变体修饰符来定位媒体查询,如响应式断点、深色模式、首选减少运动等。例如,用于仅在中等屏幕尺寸及以上位置应用该实用工具。md:top-6``top-6

<div class="top-4 md:top-6"><!-- ... -->
</div>

若要了解详细信息,请查看有关响应式设计、深色模式和其他媒体查询修饰符的文档。

2.4 自定义主题

默认情况下,Tailwind 为默认间距比例的组合以及一些其他分数值的组合提供上/右/下/左/插图实用程序。auto``full

您可以通过编辑或在文件中自定义间距比例。theme.spacing``theme.extend.spacing``tailwind.config.js

tailwind.config.js

module.exports = {theme: {extend: {spacing: {4: '0.8rem',}}}
}

或者,您可以通过编辑或在文件中仅自定义上/右/下/左/插图比例。theme.inset``theme.extend.inset``tailwind.config.js

 <div class="relative top-10 w-20 h-20 sm:w-28 sm:h-28 mx-auto bg-purple-500 rounded-lg"><div class="absolute -left-4 -top-4 p-8 bg-purple-900 rounded-lg"></div>
</div>

可以观察到-left-4就是-0.8rem = -12.8px

tailwind.config.js

module.exports = {theme: {extend: {spacing: {4: '0.8rem',}}}
}

有关自定义默认主题的详细信息,请参阅主题自定义文档。

04 【布局之Overscroll Behavior 定位偏移量】相关推荐

  1. CSS布局之浮动和定位

    目录 1. 浮动 1.1 浮动元素的特性 1.2 浮动不会压住文字 1.3 清除浮动 1.3.1 额外标签法 1.3.2 父盒子添加overflow属性 1.3.3 父盒子添加after伪元素 1.3 ...

  2. CSS Overscroll Behavior Module Level 1

    编者按:本文作者奇舞团前端开发工程师何文力,同时也是 W3C CSS 工作组成员. 6 月 6 日,W3C 发布了第一份滚动溢出行为工作组草案 CSS Overscroll Behavior Modu ...

  3. CSS3与页面布局学习总结(四)——页面布局大全BFC、定位、浮动、7种垂直居中方法...

    目录 一.BFC与IFC 1.1.BFC与IFC概要 1.2.如何产生BFC 1.3.BFC的作用与特点 二.定位 2.2.relative 2.3.absolute 2.4.fixed 2.5.z- ...

  4. Ubuntu16.04中的可重定位目标文件

    最近在看<CSAPP>这本神书,其中看到了第七章链接中的可重定位目标文件,自己动手在ubuntu16.04上试了一试,发现有很多都做了一些改动,在此记录 1.源程序 main.c stat ...

  5. Flutter基础—布局模型之层叠定位

    Stack即层叠布局控件,能够将子控件层叠排列. Stack控件的每一个子控件都是定位或不定位,定位的子控件是被Positioned控件包裹的.Stack控件本身包含所有不定位的子控件,其根据alig ...

  6. CSS静态布局——常规流,定位,浮动。

    合理的网页布局方式 合理的网页布局可以使网页内容以整洁有序的方式展示给用户.凌乱的布局则会使网页的信息无法正确传达,用户的目的没有达到等问题. 合理的网页布局应有: 1.合理地把页面切分为多个具有具体 ...

  7. Flutter教程04——布局01

    目录 1.约束 1.1BoxConstraints 1.2ConstrainedBox 1.3SizedBox 1.4多重限制 1.5UnconstrainedBox 2.线性布局 2.1Row 2. ...

  8. 27.html的定位(position)和偏移量(offset)

    文章目录 定位 偏移量(offset) 相对定位 绝对定位 固定定位 粘滞定位 定位 定位(position)是一种高级的布局手段,通过定位可以将元素摆放到页面的任意位置 可选值: static:默认 ...

  9. CSS布局相关知识(四):定位(相对、绝对、固定、粘滞)、层级

    一.定位 position 定位是什么: 定位是一种更加高级的布局手段,通过定位可以将元素摆放到页面的任意位置 怎么设置定位: 使用position属性来设置定位,可选值: static 默认值,元素 ...

最新文章

  1. 预计2020年传感器需求超一万亿个
  2. 老生常谈 String、StringBuilder、StringBuffer
  3. 2021年春季学期-信号与系统-第三次作业参考答案-第二道题
  4. python程序员又叫什么-Python程序员都知道的入门知识の四
  5. 用DataTable.Merge()解决了一个排序问题
  6. 为iPhone 12上市做准备,台积电月底前投产A14 Bionic芯片
  7. django项目部署服务器后无法发送邮箱 错误信息:Connection unexpectedly closed
  8. exescope使用
  9. 修改注册表解决 Win7 DbgView 不显示调试信息
  10. 麒麟软件、麒麟操作系统、银河麒麟、中标麒麟、优麒麟、国产操作系统下载。
  11. 6th WEEK BLOG:CSS中的单位(PS调色板)(doing)
  12. MATLAB求函数零点—fzero函数
  13. 图像生成质量fid、inception score、KID计算
  14. 消费者理论:效用函数
  15. 【酸甜苦辣】记迭代一的酸甜苦辣(妍喆篇)
  16. 存款利息计算器html代码,html+jQuery简单的利息计算器
  17. 使用Git克隆vue-element-admin项目报错的解决方案
  18. CDR智能填充—图形颜色填充好帮手
  19. js输出26个英文字母
  20. java输出数学和英语成绩_java 计算班里每个同学3门课(英语、数学、数据库)的平均成绩和总成绩,编写一个成绩类来实现这些功能。...

热门文章

  1. 【2023Unity游戏开发教程】零基础带你从小白到超神01——Unity简介下载和安装配置(视频资源订阅扣1私发)
  2. HTTP协议详解(超级详细)
  3. C语言-基本数据类型
  4. 2021年广东省现代农业产业园申报资助及条件,补贴5000万
  5. 超有趣的Python画图——科赫雪花
  6. [01-23][ dcwz电影合集][10部][18:30发布][亲测]
  7. phpstorm优雅的格式化php代码
  8. php查询车辆违章付费源码,全国交通违章查询
  9. ABAP 人民币大小写转换程序
  10. selenium控制鼠标下滑