【发布时间】:2019-08-16 23:33:04
【问题描述】:
在使用 CSS 列时,图像项目符号会部分显示在两列中。任何想法如何让子弹图像在列中断时留在自己的列中?
尝试了其他堆栈溢出问题的一些答案,但这些都没有奏效。
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
column-break-inside: avoid;
我可以让它正常工作的唯一方法是减小图像的大小或增加 li 元素之间的边距。我需要这个大小的子弹(宽度:42px,高度:40px)以匹配设计师的组合。
下面是我正在做的简单复制。
div {
width: 50%;
margin: 0 auto;
}
ul {
list-style-type: none;
columns: 2;
column-gap: 4rem;
line-height: 28px;
margin:0;
padding: 0;
}
li {
font-size:21px;
position: relative;
margin-bottom: 2rem;
padding-left: 4rem;
}
li::before {
content: '';
position: absolute;
width: 42px;
height: 40px;
top: 0;
left: 0;
background-image: url(https://picsum.photos/42/40);
border-radius: 50%;
background-size: contain;
background-repeat: no-repeat;
}
<div>
<ul>
<li>Airy, open floor plans</li>
<li>Sleek kitchens with stainless-steel appliances</li>
<li>Brushed-nickel finishes and plank flooring in living area</li>
<li>Carpeted bedroom</li>
<li>Individual washer and dryer</li>
<li>Exceptional Views</li>
<li>Ceramic tiled baths</li>
<li>Generous closet and storage space</li>
<li>Loft style with spiral stairs and private roof access*</li>
</ul>
</div>
这是 CodePen 的链接,您可以查看结果。
【问题讨论】:
-
我认为是图片指定的宽高所致。
标签: css css-multicolumn-layout