1、span直接一行
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <style type="text/css"> span{ background-color: red; } </style> </head> <body> <span>1</span><span>2</span> </body> </html>
2、float浮動
<style type="text/css"> span{ background-color: red; float: left; } </style> </head> <body> <span>1</span> <span>2</span> </body>
3、父級元素添加font-size:0;子集元素font-size:自己根據效果添加數值
<style type="text/css"> .div{ font-size: 0px; } span{ font-size: 12px; } </style> </head> <body> <div class="div"> <span>1</span> <span>2</span> </div> </body>
4、由於內層border和外層border引起的空隙
border-right:根據效果自己調整數值