草庐IT

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

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

html - :last-child not working as expected?

问题出在这个CSS和HTML中。这是一个linktojsFiddle带有示例代码。HTML1234CSSli.complete:last-child{background-color:yellow;}li.complete:last-of-type{background-color:yellow;}难道这两行CSS中的任何一行都不应该以具有“完整”类的最后一个li元素为目标吗?jQuery中的这个查询也不以它为目标:$("li.complete:last-child");但是这个确实:$("li.complete").last();li{background-color:green;}

html - :last-child not working as expected?

问题出在这个CSS和HTML中。这是一个linktojsFiddle带有示例代码。HTML1234CSSli.complete:last-child{background-color:yellow;}li.complete:last-of-type{background-color:yellow;}难道这两行CSS中的任何一行都不应该以具有“完整”类的最后一个li元素为目标吗?jQuery中的这个查询也不以它为目标:$("li.complete:last-child");但是这个确实:$("li.complete").last();li{background-color:green;}

ios - :nth-child not working on iosSafari 8

我使用的是装有ios8.02和iosSafari8的iPad。.itemgrid-3cols.item:nth-child(3n+1){clear:left;}我检查了浏览器检查器,iosSafari将上述样式规则应用于每个第1、3、7、8和9个.item@mediaonlyscreenand(max-width:959px)and(min-width:768px).itemgrid-2cols.item:nth-child(2n+1),.itemgrid-3cols.item:nth-child(2n+1),.itemgrid-4cols.item:nth-child(2n+1),.