综合一区-免费污视频-天天操综合网-又黄又爽的网站-日韩中文字幕一区二区三区-狠狠操狠狠-风间由美一区-自拍色图-久草热在线-椎名空在线-亚洲av无码国产精品久久-夜夜se-成人涩涩软件-国产精品第-亚洲自拍中文字幕-久草视频中文在线-日本黄页网站免费大全-双性人做受视频-中国一级免费毛片-三级黄片毛片

display:inline-block 去除間隙

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

先寫出代碼


核心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>