CSS - width not honored on span tag

后端 未结 5 1549
青春惊慌失措
青春惊慌失措 2021-02-06 23:26

I have a issue with one of my spans. Please consider the following styles:

.form_container .col1che
{
float: left; 
width: 4%; 
text-align: left;    
}

.form_c         


        
5条回答
  •  时光取名叫无心
    2021-02-06 23:47

    Span is an inline element and you can therefore not set a width. To set a width you must first set it to a block element with

    display:block;
    

    After that you can set a width. Since span is a native inline element, you can use inline-block too and it will even work in IE:

    display:inline-block;
    

提交回复
热议问题