草庐IT

html - 如何使用 nth-child 对带有 rowspan 的表进行样式设置?

我有一个表,其中一行使用rowspan。所以,.................................我想使用第nth-child伪类为每一行添加背景颜色,但是rowspan把它搞砸了;它将背景颜色添加到带有rowspan的行下方的行,而实际上我希望它跳过该行并移动到下一行。有没有办法让第nth-child做一些聪明的事情,或者在选择器中使用[rowspan]来解决这个问题?所以在这种情况下,我希望背景颜色位于第1行和第4行,然后是第6、8、10行,依此类推(因为这些都没有行跨度)?这就像如果我看到一个rowspan,然后我希望第n个child将1加到n,然后继续。可能没有办

html - 第 n 个 child ()还是第一个 child ?如何选择第一个和第二个 child

我想选择无序列表中的前两个列表项。我可以这样选择第一项:ulli:nth-child(1)a{background:nonerepeatscroll00beige;}或ulli:first-childa{background:nonerepeatscroll00beige;}我想同时选择第一个和第二个订单项-我该怎么做? 最佳答案 要选择第一个和第二个child,您可以使用单个:nth-child()伪类,如下所示:ulli:nth-child(-n+2)a{background:nonerepeatscroll00beige;}

html - 第 n 个 child ()还是第一个 child ?如何选择第一个和第二个 child

我想选择无序列表中的前两个列表项。我可以这样选择第一项:ulli:nth-child(1)a{background:nonerepeatscroll00beige;}或ulli:first-childa{background:nonerepeatscroll00beige;}我想同时选择第一个和第二个订单项-我该怎么做? 最佳答案 要选择第一个和第二个child,您可以使用单个:nth-child()伪类,如下所示:ulli:nth-child(-n+2)a{background:nonerepeatscroll00beige;}

html - 如何使用变换:translateX to move a child element horizontally 100% across the parent

全部,我希望能够使用translateX为子元素设置100%的动画(即从左边缘到右边缘)。挑战在于translateX中的百分比指的是元素本身,而不是父元素。因此,例如,如果我的html如下所示:我的CSS是这样的(省略了供应商前缀):#parent{position:relative;width:300px;height:100px;background-color:black;}#child{position:absolute;width:20px;height:100px;background-color:red;transform:translateX(100%);}这是行不通

html - 如何使用变换:translateX to move a child element horizontally 100% across the parent

全部,我希望能够使用translateX为子元素设置100%的动画(即从左边缘到右边缘)。挑战在于translateX中的百分比指的是元素本身,而不是父元素。因此,例如,如果我的html如下所示:我的CSS是这样的(省略了供应商前缀):#parent{position:relative;width:300px;height:100px;background-color:black;}#child{position:absolute;width:20px;height:100px;background-color:red;transform:translateX(100%);}这是行不通

html - CSS 在每第 n 个 child 后清除

我在一个容器内有多个宽度相同的元素。由于元素的高度不同,对齐存在问题,您可以在下图中看到。我想在每第3个元素之后清除而不更改html标记,以便第4个元素进入下一行。我正在尝试添加nth-child(3):after,但似乎不起作用。代码如下:HTML:Loremipsumdolorsitamet,Loremipsumdolorsitamet,consecteturadipiscingelit.Loremipsumdolorsitamet,Loremipsumdolorsitamet,LoremipsumdolorsitametCSS:.item:nth-child(3):after{c

html - CSS 在每第 n 个 child 后清除

我在一个容器内有多个宽度相同的元素。由于元素的高度不同,对齐存在问题,您可以在下图中看到。我想在每第3个元素之后清除而不更改html标记,以便第4个元素进入下一行。我正在尝试添加nth-child(3):after,但似乎不起作用。代码如下:HTML:Loremipsumdolorsitamet,Loremipsumdolorsitamet,consecteturadipiscingelit.Loremipsumdolorsitamet,Loremipsumdolorsitamet,LoremipsumdolorsitametCSS:.item:nth-child(3):after{c

html - 如何组合:first-child and :hover?

我有一个用于菜单的无序列表。每个元素都有一个背景图像和一个:hover图像。第一个元素的背景图片与其余元素不同,因此我使用以下样式对其进行样式设置,效果很好:#prodNavBarul:last-childli:first-child{...}因为我也想在这个元素上使用翻滚图像,所以我尝试添加:hover,如下所示:#prodNavBarul:last-childli:first-child:hover{...}...但这行不通。组合:first-child和:hover的语法是什么? 最佳答案 链接:first-child和:ho

html - 如何组合:first-child and :hover?

我有一个用于菜单的无序列表。每个元素都有一个背景图像和一个:hover图像。第一个元素的背景图片与其余元素不同,因此我使用以下样式对其进行样式设置,效果很好:#prodNavBarul:last-childli:first-child{...}因为我也想在这个元素上使用翻滚图像,所以我尝试添加:hover,如下所示:#prodNavBarul:last-childli:first-child:hover{...}...但这行不通。组合:first-child和:hover的语法是什么? 最佳答案 链接:first-child和:ho

html - 大于和小于的 CSS nth-child

在我的HTML中,....................................在上面的HTML中,我有container类。在我的CSS中,我需要向.container:nth-child(3,4,5,6,..andsoon)添加一些样式。意味着我需要应用除1和2之外的所有nth-child。 最佳答案 :nth-child()不适用于类,它会查找元素本身。您需要用包装器包装.containerdiv并使用以下内容:.wrapperdiv:nth-child(n+3){/*putyourstyleshere...*/}W