less (五) 父级选择 &

这个是什么意思呢,我们来看例子:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="sty.css">
</head>
<body>
<div>
<a href="#">父级选择 & </a>
</div>
</body>
</html>



上面是一个html页面,我们给其添加css 样式如下:


div{width:500px; height:500px; border:1px solid red;}
div a{color:orange;}
div a:hover{color:red;}


上面的超链接部分颜色是橘黄色,并且添加了hover改变样式;


我们同样的样式使用 less:

div{
width:500px;
height:500px;
border:1px solid red;
a{
color:orange;
&:hover{
color:red;
}
}
}


我们可以看到,&的作用相当于 a ,指向的是a ;

linux-5.10.117/arch/arm/mach-sstar/Kconfig中 menuconfig ARCH_SSTAR bool "Sstar ARM SoCs" if ARCH_SSTAR config SS_DUALOS bool "Sstar Dual-OS" choice prompt "Select types of Sstar Dual-OS" depends on SS_DUALOS config LH_RTOS bool "Enable Hypervisor" if ARCH_MULTI_V7 help Enable LH + RTOS. config SS_AMP bool "Enable Sstar AMP" if ARCH_MULTI_V7 help Enable Sstar AMP. endchoice config ENABLE_METHOD_PSCI bool "Use enable method with ARM PSCI" select ARM_PSCI default n config SSTAR_CLK_IGNORE_UNUSED bool "Ignore CLK unuse flow" default n config CNTVOFF_INITED bool "cntvoff has inited" default n config MONITOR_FIRMWARE bool "Have monitor firmware(TF-A or SMF)" default n config MODULES_AREA_SIZE hex "Modules area size" depends on MMU &amp;&amp; THUMB2_KERNEL default 0x00800000 help Config memory use for modules install. Because ARM can only branch relatively within +/- 32MB. If the difference between the lowest module address and the highest of .text is greater than 32MB, it's impossible to load modules they will fail to link. config DISABLE_DUALOS_NODE bool "Disable Dual-OS node" depends on SS_DUALOS default n comment "Options" config SSTAR_DTB_NAME string "Sstar DTB name" default "" config SSTAR_BUILTIN_DTB bool "Sstar built-in DTB" default y config MS_L2X0_PATCH bool "L2X0 patch" depends on CACHE_L2X0 default y config MS_KERNEL_TYPE string default "" config MS_ARMV7_XIP bool default y depends on XIP_KERNEL config SSTAR_CHIP_NAME string default $(SSTAR_CHIP_NAME) config SSTAR_SHORT_NAME string "Short Name" default "" config SSTAR_IRQ_DEBUG_TRACE bool "SSTAR_IRQ_DEBUG_TRACE" default n config SS_GIC_SET_MULTI_CPUS bool "Set GIC affinity to multiple CPUs according to affinity_hint" depends on SMP default y config SKIP_SQUASHFS_BAD_BLOCK bool "Skip squashfs bad block" depends on MTD default y menu "Fast boot" config SS_BUILTIN_UNFDT bool "FB_DTS: Builtin unflatted device tree" depends on SSTAR_BUILTIN_DTB default n config FB_DTS_SKIP_CRC bool "FB_DTS: Skip check DTB CRC " default n config FB_DTS_SCAN_MEMORY_ONCE bool "FB_DTS: Only search once for memory node" default n config FB_DTS_SKIP_ATAGS_TO_FDT bool "FB_DTS: Search ATAG_INITRD2 and ATAG_CMDLINE from atags instead of early_atags_to_fdt" default n config DISABLE_CLK_DEBUGFS_SUPPORT bool "Do not create the debugfs clk directory" default y config DEFERRED_INIICALLS bool "Support deferred initcalls" default y config DEFERRED_INIICALLS_SLAB_SYSFS bool "defer slab_sysfs_init" depends on DEFERRED_INIICALLS default n config DEFERRED_INIICALLS_PARAM_SYSFS bool "defer param_sysfs_init" depends on DEFERRED_INIICALLS default n config DEFERRED_INIICALLS_PPERF_SYSFS bool "defer perf_event_sysfs_init" depends on DEFERRED_INIICALLS default n config DEFERRED_INIICALLS_MORE_SYSFS bool "defer irq_sysfs_init, init_clocksource_sysfs,clockevents_init_sysfs" depends on DEFERRED_INIICALLS default n config DEFERRED_CREATE_DTS_SYSNODE bool "defer of_core_init" depends on DEFERRED_INIICALLS default n config DEFERRED_LINUX_ADAPTOR_INIT bool "defer linux_adaptor_init" depends on (DEFERRED_INIICALLS &amp;&amp; SS_RTK_MI_ADAPTOR) default n config DEFERRED_CRYPTIO_WQ_INIT bool "defer crypto_wq_init" depends on DEFERRED_INIICALLS default n config DEFERRED_RTC_HCTOSYS bool "defer rtc_hctosys" depends on DEFERRED_INIICALLS default n config CRYPTO_MANAGER_NO_TESTS_THREAD bool "Do not create cryto test thread" depends on CRYPTO_MANAGER_DISABLE_TESTS default n config WAIT_TASK_INACTIVE_SPEED_UP bool "WAIT_TASK_INACTIVE speed up" depends on SMP default y config DUALOS_SKIP_CHOSEN_DTS bool "Skip scan node of chosen" default n config DUALOS_SKIP_MEMNODE_DTS bool "Skip scan node of memory" default n config DUALOS_SKIP_RESMEMORY_DTS bool "Skip scan node of reserved-memory" default n config DUALOS_SKIP_EARLY_PRINT bool "Skip early_print" default n endmenu menu "Light memory footprint" config EMAC_RX_DESC_NUM_CUSTOMIZED bool "Customized the number of EMAC Rx descriptors" depends on SSTAR_EMAC default n config EMAC_RX_DESC_NUM hex "EMAC Rx descriptor number" depends on EMAC_RX_DESC_NUM_CUSTOMIZED default 0x40 help more EMAC Rx descriptors can avoid Rx packets loss during CPU busy, however it consumes more memory usage also. 0x40 is the minimal value recommended, it should not be less than 0x40. config SLUB_SYSFS_DISABLE bool "Disable slab sysfs" depends on SLUB default n config KERNEL_PARAM_SYSFS_DISABLE bool "Disable kernel built-in parameters sysfs" default n config DTS_SYSFS_DISABLE bool "Disable device tree sysfs" default n config WQ_SYSFS_DISABLE bool "Disable workqueue sysfs" default n config IRQ_SYSFS_DISABLE bool "Disable irq sysfs" default n config MMC_IO_SCHED_DISABLE bool "Disable mmc block IO scheduler" default n config MMC_QUEUE_DEPTH_CUSTOMIZED bool "Customized the depth of mmc request queue" depends on MMC_BLOCK default n config MMC_QUEUE_DEPTH hex "mmc request queue depth" depends on MMC_QUEUE_DEPTH_CUSTOMIZED default 0x20 help Specify the mmc queue depth to smaller number to save memory usage. The original queue depth is 64, which is hard-coded as MMC_QUEUE_DEPTH in drivers/mmc/core/queue.c. endmenu config MP_DEBUG_TOOL_MEMORY_USAGE_MONITOR bool "To monitor the order and migratetype of buddy system pages, and the page_alloc time cose" default n config MP_DEBUG_TOOL_MEMORY_USAGE_TRACE bool "Tools to trace all page allocation, we can used it to analysis mem leak, or trace migration failed pages" default n if MP_DEBUG_TOOL_MEMORY_USAGE_TRACE choice prompt "MAX_STACK_COUNT" default MAX_STACK_COUNT_2048 config MAX_STACK_COUNT_1024 bool "1024 count" config MAX_STACK_COUNT_2048 bool "2048 count" config MAX_STACK_COUNT_4096 bool "4096 count" config MAX_STACK_COUNT_6144 bool "6144 count" config MAX_STACK_COUNT_8192 bool "8192 count" endchoice endif config LINUX_ON_SS_HYPERVISOR bool "Linux run on Sstar hypervisor" default n source "arch/arm/mach-sstar/$(SSTAR_CHIP_NAME)/Kconfig" endif 如何确定SSTAR_CHIP_NAME的值
最新发布
09-20
Less 中,虽然没有传统意义上的“选择器”,但通过 `&amp;` 符号可以实现对选择器的引用,从而构建出与元素相关的嵌套结构。这一特性使得在编写 CSS 预处理器代码时,能够更灵活地控制选择器的组合和生成结果。 ### 基本用法:使用 `&amp;` 引用选择器 在 Less 中,`&amp;` 表示对当前嵌套层选择器的引用。它可以用于生成交集选择器、伪类选择器,以及更复杂的嵌套结构。 例如,以下代码定义了一个类 `.demo`,并在其内部使用 `&amp;` 来生成 `.demo-title` 选择器: ```less .demo { &amp;-title { text-align: center; } } ``` 编译后生成的 CSS 为: ```css .demo-title { text-align: center; } ``` 该方式常用于构建 BEM 风格的类名结构,提升代码的可维护性和语义清晰度[^3]。 ### 伪类与状态的引用 除了构建类名,`&amp;` 还可以用于生成伪类或状态选择器。例如,在 `.textarea1` 类中,使用 `&amp;:hover` 可以生成针对该类的悬停状态样式: ```less .textarea1 { margin: 10 * 10px; padding: ~"10 * 10px"; &amp;:hover { color: yellow; } } ``` 编译后为: ```css .textarea1 { margin: 100px; padding: 10 * 10px; } .textarea1:hover { color: yellow; } ``` 这种方式使得伪类的编写更加直观,并且保持了代码结构的层次感[^2]。 ### 嵌套结构中的选择器引用 在更复杂的嵌套结构中,`&amp;` 也可以用于将子选择器移至之前,改变默认的嵌套顺序。例如: ```less .contain { h1 &amp; { width: 200px; height: 300px; } } ``` 该写法表示将 `.contain` 放在 `h1` 之后,生成的选择器为: ```css h1 .contain { width: 200px; height: 300px; } ``` 这种写法在需要根据 HTML 结构反向构建选择器时非常有用[^1]。 ### 多层嵌套中使用 `&amp;` 在多层嵌套中,`&amp;` 也可以用于构建更复杂的选择器组合。例如: ```less #son { ul { li { .contain &amp; { height: 100px; background-color: #fff; } } } } ``` 该写法会生成: ```css .contain #son ul li { height: 100px; background-color: #fff; } ``` 这种结构在构建模块化样式时非常有用,能够清晰地表达层关系[^1]。 ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值