html选择器选第一个结束,html – 新行上第一个和最后一个内联块元素的选择器...

没有CSS唯一的方式.我加了

the JavaScript solution in your fiddle.

作为解决方法,您可以将固定百分比宽度分配给列表项,并使用CSS媒体查询根据屏幕大小增加/减少宽度.这样你就可以准确地知道多少个物品符合一条线,这样就可以让您对特定元素进行风格化. SASS可以使写作重复性CSS更容易.粗略的轮廓(打开整页并调整浏览器的大小):

ul {

margin: 0;

padding: 0;

list-style-type: none;

}

li {

float: left;

Box-sizing: border-Box;

margin-bottom: .5em;

border: thin solid #EEE;

padding: 1em;

white-space: nowrap;

overflow: hidden;

text-overflow: ellipsis;

background-color: #CEF;

}

li:first-child {

border-top-left-radius: 1em;

border-bottom-left-radius: 1em;

}

li:last-child {

border-top-right-radius: 1em;

border-bottom-right-radius: 1em;

}

@media (min-width: 600px) and (max-width: 799px) {

/* 4 items per row */

li {

width: 25%;

}

/* match 4,8,12,...*/

li:nth-child(4n+4) {

border-top-right-radius: 1em;

border-bottom-right-radius: 1em;

}

/* match 5,9,13,... */

li:nth-child(4n+5) {

border-top-left-radius: 1em;

border-bottom-left-radius: 1em;

}

}

@media (max-width: 599px) {

/* 3 items per row */

li {

width: 33.3333%;

}

/* match 3,6,... */

li:nth-child(3n+3) {

border-top-right-radius: 1em;

border-bottom-right-radius: 1em;

}

/* match 4,7,10,... */

li:nth-child(3n+4) {

border-top-left-radius: 1em;

border-bottom-left-radius: 1em;

}

}

  • Praesent ultricies libero
  • Aenean in velit vel
  • Ut consequat odio
  • Integer convallis sapien
  • Fusce placerat augue
  • Vestibulum finibus nunc
  • Nulla consectetur mi
  • Ut sollicitudin metus
  • Maecenas quis nisl sit
  • Vivamus eleifend justo
  • Duis ut libero pharetra
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值