久久精品视频只有这里-插入女人小穴视频在线观看-日韩欧美精品在线观看免费-综合亚洲欧美日韩综合久久

display:inline-block 去除間隙

2016/12/2 8:35:14   閱讀:1770    發布者:1770

先寫出代碼


核心css代碼:

.sample0{display: inline-block;height: 40px;width: 40px;color: #ffffff;
background-color: red; text-align: center;font-size: 26px;} .sample1{display: inline-block;height: 40px;width: 40px;color: #ffffff;
background-color: orange;text-align: center;font-size: 26px; .sample2{display: inline-block;height: 40px;width: 40px;color: #ffffff;
background-color: blue;text-align: center;font-size: 26px;}

核心html代碼:

<div class="sample0">0</div> 
<div class="sample1">1</div> 
<div class="sample2">2</div>

 

 

 

問題: display:inline-block的塊之間,有空隙


 

原因:換行顯示或空格分隔

 

解決方案一:margin 設置負值

核心 css 代碼

.sample0{display: inline-block;height: 40px;width: 40px;color: #ffffff;
background-color: red; text-align: center;font-size: 26px;margin-right: -4px;} .sample1{display: inline-block;height: 40px;width: 40px;color: #ffffff;
background-color: orange;text-align: center;font-size: 26px;margin: 0;margin:0 -4px;} .sample2{display: inline-block;height: 40px;width: 40px;color: #ffffff;
background-color: blue;text-align: center;font-size: 26px;margin-left: -4px;}

 

解決方案二: 將html元素寫緊湊(消除空格)

核心 html 代碼

<div class="sample0">0</div><div class="sample1">1</div><div class="sample2">2</div>