简体   繁体   English

如何在第3个和第4个列表项之间插入关键点,但是要成为父元素的宽度?

[英]How to insert a keyline between 3rd and 4th list item, but be the width of the parent element?

I'm trying to create a keyline between two list items with class names using nth-child and after. 我正在尝试使用nth-child和after在具有类名的两个列表项之间创建关键行。 The trick here is that the list items are ~250px wide, float:left and I want the keyline to extend the width of the parent div that is 1000px wide, after the third list item. 这里的技巧是,列表项的宽度约为250px,float:left,我希望键线在第三个列表项之后将父div的宽度扩展为1000px。 So far I have been able to create the keyline after the third list item, but it's width remains 250px wide: 到目前为止,我已经能够在第三个列表项之后创建关键行,但是其宽度仍然为250px宽:

  #FS-TilesContainer { margin: auto; width: 1000px; } .FS-Tile { float: left; overflow: hidden; width: 225px; margin: 0 0 47px 35px; } .FS-Tile:nth-child(-n+3) { width: 300px; } .FS-Tile:nth-child(3)::after { content:''; border-top: 5px solid #EAEAEA; display: block; width: 1000px; left: 0; } 
  <div id="FS-TilesContainer"> <ul id="FS-TilesGrid"> <li class="FS-Tile"></li> <li class="FS-Tile"></li> <li class="FS-Tile"></li> <li class="FS-Tile"></li> <li class="FS-Tile"></li> <li class="FS-Tile"></li> <li class="FS-Tile"></li> <li class="FS-Tile"></li> <li class="FS-Tile"></li> </ul> </div> 

Here you can see in this code. 在这里您可以看到此代码。

You need to give position:absolute in this code 您需要给出position:absolute此代码中的position:absolute

.FS-Tile:nth-child(3)::after {
    content: '';
    border-top: 5px solid #EAEAEA;
    display: block;
    width: 1000px;
    left: 0;
    position: absolute; //new added
}

Check this hope it will helpful to you. 选中此希望对您有帮助。

 #FS-TilesContainer { margin: auto; width: 1024px; } .FS-Tile { float: left; overflow: hidden; width: 221px; margin: 0 0 47px 35px; } .FS-Tile:nth-child(-n+3) { width: 300px; } .FS-Tile:nth-child(3)::after { content:''; border-top: 5px solid #EAEAEA; display: block; width: 1000px; left: 0; position:absolute; } 
 <div id="FS-TilesContainer"> <ul id="FS-TilesGrid"> <li class="FS-Tile">test</li> <li class="FS-Tile">test1</li> <li class="FS-Tile">test2</li> <li class="FS-Tile">test3</li> <li class="FS-Tile">test4</li> <li class="FS-Tile">test5</li> <li class="FS-Tile">test6</li> <li class="FS-Tile">test7</li> <li class="FS-Tile">test8</li> </ul> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用jQuery设置第3,第4或第5个表格单元格 - How to style 3rd, 4th or 5th table cell using jQuery 如何在Javascript中用空格替换第三个连字符和用冒号替换第四个连字符 - How to replace 3rd hyphen with empty space and 4th hyphen with colon in Javascript 我需要显示有多少 '1' 值有第 3 列和第 4 列 - I need to display that how many '1' values have 3rd and 4th columns jQuery如何获取第二和第三TD内容取决于第四点击 - JQuery how to fetch 2nd and 3rd TD content depend on 4th td click 如何在 JavaScript onclick 上显示不同的图像并在第 3 次或第 4 次单击时显示相同的图像 - How to show different image on JavaScript onclick and display the same image on 3rd or 4th click 从数组中删除 5 个元素中的第 3 个和第 4 个 - Removing every 3rd & 4th out of 5 elements from array 定位到列表的第3、6、9等元素 - Targeting every 3rd, 6th, 9th etc element of a list 隐藏1、3、4、6、7、9、10、12 div容器 - Hide 1st, 3rd, 4th, 6th, 7th, 9th, 10th, 12th div container 我的滑块仅显示第1和第3个滑块,但不显示表格的第2和第4个滑块 - My slider only shows 1st and 3rd slider but not the 2nd and 4th slider for table jQuery图像滑块首先加载第三和第四图像的合并,而不是第一 - jQuery image slider first loading amalgimation of 3rd and 4th images instead of 1st
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM