CSS 行内元素嵌套,换行后首字符样式丢失怎么办?
css 中行内样式套行内样式,换行后首字符无法定位
问题:
使用行内元素定位时,换行后的首字符不显示对应的样式,如给子元素添加下划线。
代码:
<span class="row"> <span>最</span> <span>近</span> <span>的</span> <span>已</span> <span>定</span> <span>位</span> <span>祖</span> <span>先</span> <span>元</span> <span>素</span> <span>根</span> <span>据</span> <span>正</span> <span>常</span> <span>文</span> <span>档</span> <span>流</span> <span>进</span> <span>行</span> <span>定</span> <span>位</span> <span>你</span> </span>
解决方法:
给 span 设置为行内块元素,即 display: inline-block。
修改后的代码:
.row span { position: relative; display: inline-block; }
以上就是CSS 行内元素嵌套,换行后首字符样式丢失怎么办?的详细内容,更多请关注硕下网其它相关文章!