注意
此页为于 SCP 维基内部使用的"组件"页。用于在其他页面中引用。
未经组件作者或工作人员允许,请勿修改此页的内容。
这是什么
一个图像轮播组件,它能循环显示多张图像,而不只是单独一张。
使用方法
在你需要图像轮播框的地方,插入如下代码而不是标准插图方块。
确保你要使用的图像已经上传到了你的页面里。如果你选择无视这条睿智的忠告并在设置好轮播组件之后才上传图像,那么你的图像会无法显示,除非彻底刷新(Ctrl+Shift+R)页面。
[[include :scp-wiki-cn:component:carousel
| images=photograph.png,old-map.png,jumpscare.gif
| caption=一系列图片。
| interval=5
| wiki=scp-wiki-cn
| page=SCP-173
| width=300px
| height=240px
| position=right
| no-caption=false
| background=white
| options=yes
]]
使用图像轮播框会带来一些可访问性问题 - 对某些用户来说,连续的移动会非常分散注意力。强迫读者等待阅读文章的图片也不是一个很好的主意。这个组件也会因为在非交互的文本中强行添加交互性而惹恼你的读者。如有可能,我建议不要使用此组件。使用一系列标准插图方块作为代替。
每个选项都是什么
以斜体字标注的均为可选项。其他则是必须要添加的。
如果你省略了可选项,则它将设置为其默认值。如果你省略了必选项,则轮播框无法正常工作。
这些图像会以你列举的顺序出现在轮播里。
(可选) 一系列链接至每个图像的链接,由半角逗号","分割。若填写本参数,确保链接数量与图像数量一致。
(可选) 可选。出现在轮播框下方的说明文字。
如果没有说明文字,请确保将 no-caption 设置为 true。
默认值:"{$caption}"
(可选) 可选。如果你将它设置为非零的数字,那么轮播框会在相应秒数之后自动转至下一张图像。
如果用户点击箭头来手动换图,或者如果他们的鼠标正悬停在轮播框上,图像就不会轮换。
默认值:"0"
(可选) 轮播框里最宽的图像宽度。
默认值:"300px"
(可选) 轮播框里最高的图像高度。
默认值取决于浏览器
(可选) 轮播框在页面中的水平位置。"left"为左,"right"为右,"center"为中。
默认值:"right"
(可选) 如果你不想要说明文字,将之设置为"true"。不然,则留空,或者设置为"false",或把这行整个去掉。
默认值:"false"
(可选) 图像的背景颜色。
默认值:"transparent"(透明)
默认值:"yes"
我想让轮播框横跨整个页面!
将 width 设置为"100%",position 设置为"center"。
我将宽度/高度设置为最大图像的尺寸了,但这东西实在太大了!
用小一点的数字,或者把图像改小一点。
{$caption}
基础代码
轮播框的 HTML 结构
<htmlng-app="carousel"ng-controller="CarouselController"><head><scriptsrc="https://fastly.jsdelivr.net/npm/angular@1.7.2/angular.min.js"></script><scriptsrc="https://scp-wiki.wdfiles.com/local--code/component%3Acarousel/2"></script><linkhref="https://d3g0gp89917ko0.cloudfront.net/v--edac79f846ba/common--theme/base/css/style.css"rel="stylesheet"><linkhref="https://sigma9.scpwikicn.com/cn/cn/sigma9_ch.min.css"rel="stylesheet"><linkhref="https://scp-wiki.wdfiles.com/local--code/component%3Acarousel/4"rel="stylesheet"></head><body><divclass="wrapper"id="background"><divclass="carousel"><divclass="horsie"ng-repeat="image in images track by $index"ng-class="[index > $index ? 'past' : null, index === $index ? 'present' : null, index < $index ? 'future' : null]"><imgng-src="{{image}}"ng-if="!links[$index]"><ahref="{{links[$index]}}"target="_blank"ng-if="links[$index]"><imgng-src="{{image}}"></a></div></div><divclass="arrow decrementor"ng-class="index === 0 ? 'inactive' : 'active'"ng-click="increment(-1)"><divclass="image"></div></div><divclass="arrow incrementor"ng-class="index === images.length-1 ? 'inactive' : 'active'"ng-click="increment(1)"><divclass="image"></div></div><divclass="bubble-holder"ng-class="[options === 'yes' ? null : 'invisible']"><divclass="bubble"ng-repeat="image in images track by $index"ng-class="[index === $index ? 'present' : null]"ng-click="selectImage($index)"></div></div><divclass="control play"ng-click="control('play')"ng-class="[state === 'play' ? 'active' : null, options === 'yes' ? null : 'invisible']"></div><divclass="control pause"ng-click="control('pause')"ng-class="[state === 'pause' ? 'active' : null, options === 'yes' ? null : 'invisible']"></div></div></body></html>