该怎么解决??
父元素可以考虑用 flex 布局,子元素设置 line-height 为 normal。
<div class="chip">
<div class="chip-label">Text Content</div>
</div>
样式
.chip {
padding-left: 10px;
padding-right: 10px;
font-weight: normal;
display: inline-flex;
box-sizing: border-box;
vertical-align: middle;
align-items: center;
margin: 2px 0;
background-color: rgba(0,0,0,0.12);
font-size: 13px;
color: #000;
height: 24px;
line-height: 24px;
border-radius: 24px;
position: relative
}
子元素就会继承父元素的 line-height,此时在微信浏览器内核中会无法显示居中。
.chip-label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
position: relative;
flex-shrink: 1;
min-width: 0;
}
处理
.weixin .chip-label {
line-height: normal;
}
6 回答5.5k 阅读✓ 已解决
9 回答9.6k 阅读
5 回答3.8k 阅读✓ 已解决
5 回答8.2k 阅读✓ 已解决
4 回答8.2k 阅读✓ 已解决
7 回答10.2k 阅读
5 回答7.9k 阅读
考虑一下css3的flex