大佬教程收集整理的这篇文章主要介绍了少css – 有可能得到父母的父母?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在大多数情况下,您不能直接执行(请参阅异常的第二个示例).
如果祖父母是元素
这需要一些重复,但是允许祖父母不是最外层的包装(所以可能有一个伟大的祖父母).
减
grandparent { /* grandparent styles */ parent { /* parent styles */ child { /* child styles */ } } &.specialGrandpa { child { /* child styles with special Grandpa */ } } &.specialGrandma { child { /* child styles with special Grandma*/ } } }
CSS输出
grandparent { /* grandparent styles */ } grandparent parent { /* parent styles */ } grandparent parent child { /* child styles */ } grandparent.specialGrandpa child { /* child styles with special Grandpa */ } grandparent.specialGrandma child { /* child styles with special Grandma*/ }
如果祖父母是一个类,身份证等,并且是最外层的包装
在这里没有重复,但你不能在一个伟大的祖父母在混合.此外,这仅适用于LESS 1.3.1版本(早期版本不正确添加空格):
减
.grandparent { /* grandparent styles */ .parent { /* parent styles */ .child { /* child styles */ .specialGrandparent& { /* child styles with special grandparent*/ } } } }
CSS输出
.grandparent { /* grandparent styles */ } .grandparent .parent { /* parent styles */ } .grandparent .parent .child { /* child styles */ } .specialGrandparent.grandparent .parent .child { /* child styles with special grandparent*/ }
该代码通过附加到祖父选择器的“前端”,这就是为什么祖父母必须是类,ID或其他选择器本身.
附录
基于关于在跨度为空时有红色背景的评论.这不是将背景放在父母身上,而是使用孩子“假”.
span:empty:after { content: ''; position: absolute; top: -1px; right: -10px; left: -1px; bottom: -10px; display: block; BACkground-color: red; z-index: -1; }
以上是大佬教程为你收集整理的少css – 有可能得到父母的父母?全部内容,希望文章能够帮你解决少css – 有可能得到父母的父母?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。