您可能已经注意到具有独特滚动条的网站,这些网站赋予它们独特的感觉和外观,因为自定义滚动条变得越来越普遍。自定义滚动条可以通过几种不同的方式简单地实现。本文将使用最简单的方法,即 CSS。
我们使用 CSS 来增强应用程序中网页的视觉吸引力。使用 CSS,我们现在可以更改滚动条的外观。让我们看看如何使滚动条自定义箭头在移动设备上工作。
使滚动条自定义箭头在移动设备上工作
过去,网站上的滚动条可以使用非标准 CSS 属性(如scrollbar-base-color)进行修改,您可以将其应用于滚动的元素(如 )并做一些非常棒的事情。 IE 放弃了这一点。
自定义滚动条今天再次可用,尽管这次使用了 WebKit。这些属性现在使用“Shadow DOM”并且带有供应商前缀(例如:-webkit-scrollbar)。这已经存在了一段时间了。
为了获得有关使滚动条自定义箭头在移动设备上工作的更多想法,让我们看看以下示例。
示例
在下面的示例中,我们使用 webkit-scrollbar 使滚动条在移动设备上工作并将 CSS 应用于滚动条。
<!DOCTYPE html> <html> <body> <style> div{ max-width:400px; max-height:250px; overflow-y: scroll; overflow-x: hidden; } div::-webkit-scrollbar { width: 0.5em; } div::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 2px rgba(1,1,1,0.4); } div::-webkit-scrollbar-thumb { background-color: #D5F5E3; outline: 1px solid #FBFCFC; } </style> <div id="tutorial"> <img src="/static/imghwm/default1.png" data-src="https://www.tutorialspoint.com/about/images/about-mini-logo.jpg?x-oss-process=image/resize,p_40" class="lazy" alt="如何使滚动条自定义箭头在移动设备上工作?" > Tutorials Point originated from the idea that there exists a class of readers who respond better to online content and prefer to learn new skills at their own pace from the comforts of their drawing rooms.The journey commenced with a single tutorial on HTML in 2006 and elated by the response it generated, we worked our way to adding fresh tutorials to our repository which now proudly flaunts a wealth of tutorials and allied articles on topics ranging from programming languages to web designing to academics and much more. </div> </body> </html>
当脚本执行时,它将生成一个由图像、一些文本和网页上可滚动显示组成的输出。
示例
考虑以下示例,我们使用 webkit-scrollable 使内容在网页上随着箭头滚动。
<!DOCTYPE html> <html> <body> <style> .visible-scrollbar, .mostly-customized-scrollbar { display: block; width: 300px; overflow: auto; height: 150px; } .invisible-scrollbar::-webkit-scrollbar { display: none; } .mostly-customized-scrollbar::-webkit-scrollbar { width: 300px; height: 8px; background-color:#7D3C98 ; } .mostly-customized-scrollbar::-webkit-scrollbar-thumb { outline: 1px solid #FBFCFC; } </style> <div class="visible-scrollbar"> Mahendra Singh Dhoni born 7 July 1981, commonly known as MS Dhoni, is a former Indian cricketer and captain of the Indian national team in limited-overs formats from 2007 to 2017, and in Test cricket from 2008 to 2014. He is also the current captain of Chennai Super Kings in the Indian Premier League. Under his captaincy, India won the 2007 ICC World Twenty20, the 2011 Cricket World Cup, and the 2013 ICC Champions Trophy, the most by any captain. He also led India to victory in the 2010 and 2016 Asia Cup. </div> </body> </html>
运行上述脚本时,将弹出输出窗口,显示文本以及网页上显示的可滚动箭头。
示例
执行下面的代码并观察我们如何使用 webkit-scrollable 制作自定义滚动。
<!DOCTYPE html> <html> <body> <style> body { font-size: 15pt; } ::-webkit-scrollbar { width: 14px; border: 1px solid blue; } ::-webkit-scrollbar-button:single-button { background-color: fuchsia; height: 10px; width: 10px; } ::-webkit-scrollbar-thumb { background: maroon; } ::-webkit-scrollbar-track { background: silver; } ::-webkit-resizer { background: olive; } </style> <center> <img src="/static/imghwm/default1.png" data-src="https://upload.wikimedia.org/wikipedia/commons/3/3a/Ducatilogol.png?x-oss-process=image/resize,p_40" class="lazy" alt="如何使滚动条自定义箭头在移动设备上工作?" > <p>Ducati is a group of companies, best known for manufacturing motorcycles and headquartered in Borgo Panigale, Bologna, Italy. The group is owned by German automotive manufacturer Audi through its Italian subsidiary Lamborghini, which is in turn owned by the Volkswagen Group.</p> <br> <p>In the 1930s and 1940s, Ducati manufactured radios, cameras, and electrical products such as razors. Ducati also made a marine binocular called the BIMAR for the Kriegsmarine during World War II, some of which were sold on the civilian market after the war.The Ducati Sogno was a half-frame Leica-like camera which is now a collector's item.</p> </center> </body> </html>
执行脚本时,它将生成一个由文本、图像和应用 CSS 的自定义滚动条组成的输出,并显示在网页上。
以上是如何使滚动条自定义箭头在移动设备上工作?的详细内容。更多信息请关注PHP中文网其他相关文章!

Svelte Transition API提供了一种使组件输入或离开文档(包括自定义Svelte Transitions)时动画组件的方法。

前几天我只是和埃里克·迈耶(Eric Meyer)聊天,我想起了我成长时代的埃里克·迈耶(Eric Meyer)的故事。我写了一篇有关CSS特异性的博客文章,以及

文章讨论了使用CSS来获得阴影和渐变等文本效果,优化它们以进行性能并增强用户体验。它还列出了初学者的资源。(159个字符)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

Atom编辑器mac版下载
最流行的的开源编辑器

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

Dreamweaver Mac版
视觉化网页开发工具