标签根据内容自动适配大小

最近做的一个网页要用到用户的搜索记录,用标签的形式显示

做的时候就发现记录的内容是不确定的,标签的大小不好确定,用css来自动根据内容适配标签大小

.item{position: relative;height:30px;display:inline-block;*display:inline;*zoom:1;line-height: 30px;
background: #F2F7F6;border-radius: 5px;padding-left: 10px;padding-right: 10px;margin-right: 0%;margin-top: 2%;}

通过设置padding和background来实现标签效果

原文地址:https://www.cnblogs.com/heyach/p/6405893.html