CSS vertical alignment of inline/inline-block elements

后端 未结 4 1218
南旧
南旧 2020-11-22 09:36

I\'m trying to get several inline and inline-block components aligned vertically in a div. How come the span in this exam

4条回答
  •  一向
    一向 (楼主)
    2020-11-22 09:47

    Simply floating both elements left achieves the same result.

    div {
    background:yellow;
    vertical-align:middle;
    margin:10px;
    }
    
    a {
    background-color:#FFF;
    width:20px;
    height:20px;
    display:inline-block;
    border:solid black 1px;
    float:left;
    }
    
    span {
    background:red;
    display:inline-block;
    float:left;
    }
    

提交回复
热议问题