CSS 3 nth of type 仅限于 Class
nth-of-type 选择器允许您选择特定类型的每第 n 个子级。但是,将此选择限制为特定类可能具有挑战性。
问题:
您希望动态定位每三个 .module 元素,无论其标记如何。不过,nth-of-type 是根据元素类型计算的,而不是类。
解决方案:
目前没有直接的方法来限制 nth-of - 键入特定的类。一种解决方法是手动向每三个 .module 元素添加一个附加类。
例如,在提供的 HTML 中:
<section class="featured module"> <h1 id="NOT-A-VIDEO">NOT A VIDEO</h1> </section> <section class="featured module third"> <h1 id="NOT-A-VIDEO">NOT A VIDEO (3)</h1> </section> <section class="featured module"> <h1 id="NOT-A-VIDEO">NOT A VIDEO</h1> </section> <section class="featured module third"> <h1 id="NOT-A-VIDEO">NOT A VIDEO (6)</h1> </section>
然后应用以下 CSS 样式:
.featured.module.third { padding-right: 0; background: red; }
现在将使用附加的 .third 来设置 .module 类每三次出现的样式class.
注意:
此解决方法需要在添加或删除 .module 元素时进行手动维护。对于更高级的场景,请考虑使用 JavaScript 或 CSS 预处理器自动生成必要的类。
以上是如何使用 CSS'nth-of-type”将每三个元素指定为特定类?的详细内容。更多信息请关注PHP中文网其他相关文章!

是的,youshouldlearnbothflexboxandgrid.1)flexboxisidealforone-demensional,flexiblelayoutslikenavigationmenus.2)gridexcelstcelsintwo-dimensional,confffferDesignssignssuchasmagagazineLayouts.3)blosebothenHancesSunHanceSlineHancesLayOutflexibilitibilitibilitibilitibilityAnderibilitibilityAndresponScormentilial anderingStruction

重构自己的代码看起来是什么样的?约翰·瑞亚(John Rhea)挑选了他写的一个旧的CSS动画,并介绍了优化它的思维过程。

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframesispopularduetoitsversatoryand and powerincreatingsmoothcssanimations.keytricksinclude:1)definingsmoothtransitionsbetnestates,2)使用AnimatingmatematingmultationmatingMultationPropertiessimultane,3)使用使用4)使用BombingeNtibalibility,4)使用BombingingWithjavofofofofofoffo

CSSCOUNTERSAREDOMANAGEAUTOMANAMBERINGINWEBDESIGNS.1)他们可以使用forterablesofcontents,ListItems,and customnumbering.2)AdvancedsincludenestednumberingSystems.3)挑战挑战InclassINCludeBrowsEccerCerceribaliblesibility andperformiballibility andperformissises.4)创造性

使用滚动阴影,尤其是对于移动设备,是克里斯以前涵盖的一个微妙的UX。杰夫(Geoff)涵盖了一种使用动画限制属性的新方法。这是另一种方式。


热AI工具

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

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

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

SublimeText3汉化版
中文版,非常好用

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。