草庐IT

first-child

全部标签

html - 在 CSS3 中使用 nth-child() 选择 double

假设我有一个列表的以下结构:和每个宽度为50%,所以我希望每两个都具有相同的背景颜色,如下所示:我可以使用“nth-child()”CSS选择器来执行此操作以最小化代码吗? 最佳答案 ulli:nth-child(4n+1),ulli:nth-child(4n+2){background:#CCC;}ulli:nth-child(4n+3),ulli:nth-child(4n+4){background:#DDD;}这将为您提供从第1个和第2个开始的每第4个元素的颜色#CCC,以及从第3个和第4个开始的第4个元素的颜色#DDDjsf

css - :last-child works, :first-child 没有

这个问题在这里已经有了答案:CSSselectorforfirstelementwithclass(23个回答)关闭8年前。我有一个aside有两个元素。我正在尝试使用CSS来操纵:first-child但它不起作用。但是,在尝试访问:last-child时确实如此。JSFiddleHTMLProductName100–SmallProductDimensions23.75wx17.75hx28d200–LargeProductDimensions29.75wx17.75hx28dCSS.sku:first-child{display:none!important;/*doesn'th

html - 当我使用位置 :absolute in child block it does not refer parent block?

这个问题在这里已经有了答案:Positionabsolutebutrelativetoparent(5个答案)关闭9年前。在HTML中,当您在子block中使用position:absolutecss属性时,绝对值不是从父标记中获取的,而是从整个浏览器窗口引用的。示例代码如下所示。CSS.parent{width:400px;height:400px;border:1pxsolidgreen;}.child{position:absolute;width:200px;height:200px;border:1pxsolidred;bottom:0px;}

javascript - CSS : Amazingly strikethrough not working on child display:inline-block div

我有一个代码,如果我在外部div上应用text-decoration:line-through;,所有内部div元素也必须是“删除线”。这通常可以100%正常工作;但是,如果我将子元素放置为“display:inline-block”,现在应用于父div的删除线不会影响子元素的删除线。我必须将child作为display:inline-block放置,并且我需要在text-decoration:line-through;添加到parentdiv时划掉child。div{padding:10px;}#outer{background:yellow;text-decoration:line

html - 如何 'hide' :first-line for white-space:pre-line in FIREFOX browser

当我使用white-space:pre-line;word-break:break-word;...文本前多了一行。为了隐藏它,我使用了:.class:first-line{line-height:0;}...它可以在Chrome浏览器中运行,但不能在Firefox中运行。这是一个可用的fiddle,请在Firefox中打开它:https://jsfiddle.net/t3qj51co/2/ 最佳答案 为什么不修复你的HTML(demo)问题是在您的html中有一个空行。由于您使用pre-line,它也会考虑到这一点。只需删除空行即

html - CSS last-child 选择器不工作

我正在尝试将样式应用到最后一个在一个分区中。我想在不添加新类(或ID)的情况下这样做。我试过使用last-child选择器,但它不起作用。我什至尝试过声明p:last-child{font-style:italic;}对于我所有的CSS文档,这似乎没有任何效果。这是我的HTML:TheTitleSometext.Thiscollectionincludesvideo,audioandessays.Visitnow这是我的LESSCSS:.collection-container{height:200px;position:relative;background-color:@gray;

python - 使用 beautifulsoup 获取 div 中的 child 文本

您好,我想了解GooglePlay商店中某个应用的说明。(https://play.google.com/store/apps/details?id=com.wetter.androidclient&hl=de)importurllib2frombs4importBeautifulSoupsoup=BeautifulSoup(urllib2.urlopen("https://play.google.com/store/apps/details?id=com.wetter.androidclient&hl=de"))result=soup.find_all("div",{"class":

jQuery:获取ID包含部分字符串的所有 child

我有一组链接:我需要一种快速的方法来获取(例如)#parent的所有a子级,其ID包含字母i。我该怎么做? 最佳答案 使用jquerycontainsselector:$("#parent").find("a[id*='i']").each(function(){//dosomethinghere});DEMOFIDDLE 关于jQuery:获取ID包含部分字符串的所有child,我们在StackOverflow上找到一个类似的问题: https://stac

html - 使用文本溢出 : ellipsis; on a parent div when the child is an input

我在父div中有多个非换行的内联子元素,它们的width和text-overflow设置为ellipsis.当最后一个child是anchor标记时,省略号工作正常,但当它是输入时,文本只是剪辑。因为前面的元素是可变宽度的,所以我无法在最后一个输入上设置合理的最大宽度。.parent{width:120px;background:#eee;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;}link1textLoremipsumdolorlink2text有什么建议吗?这是一个JSFiddle.

html - CSS:包含文本节点的第一个 child 选择器

有什么方法可以选择作为其父元素的第一个子元素的CSS元素,计算文本节点?如果标题位于其父级的顶部,我想删除标题的上边距,但如果我使用:#contenth1{margin-top:1em;}#contenth1:first-child{margin-top:0;}并有一些HTML,比如Thisissometext.AheadingSomemoretext.边距仍然被移除。CSS中有什么方法可以防止这种情况发生吗? 最佳答案 移除margin,而不仅仅是margin-top,h1元素将下一个元素向下推#contenth1{margin-