CSS width of a tag

后端 未结 7 629
清歌不尽
清歌不尽 2020-12-07 16:36

I use tags in my module titles, e.g.

Categories.

I specify the span\'s background color/imag

相关标签:
7条回答
  • 2020-12-07 17:04

    I would use the padding attribute. This will allow you add a set number of pixels to either side of the element without the element loosing its span qualities:

    • It won't become a block
    • It will float as you expect

    This method will only add to the padding however, so if you change the length of the content (from Categories to Tags, for example) the size of the content will change and the overall size of the element will change as well. But if you really want to set a rigid size, you should do as mentioned above and use a div.

    See the box model for more details about the box model, content, padding, margin, etc.

    0 讨论(0)
提交回复
热议问题