html代碼
<li> <span class="left_item">在線</span> <img class="right_item item_img" src="../../assets/admin/image/ztree_forbid.png" alt=""/> </li>
相關css
.left_item { width: 30%; height: 100%; display: inline-block; box-sizing: border-box; vertical-align: middle; } .right_item { width: 40%; height: 100%; display: inline-block; box-sizing: border-box; vertical-align: middle; } .item_img{ width: 40px; height: 40px; } li { padding: 5px 10px; width: 100%; vertical-align: middle; box-sizing: border-box; display: block; }
效果圖:

注意點:image和span都設置
vertical-align: middle;
image的高度和寬度不能用百分比,必須寫死像素px
