如何删除内联块元素之间的空格

2020-07-23 11:16:01
要删除内联块元素之间的空格,可以使用margin-right属性。此属性用于删除其右侧元素之间的空间。此属性生成负值以保持靠近其相邻元素。

句法:

element {     margin-right:value; }

示例:

<!DOCTYPE html> <html>     <head>         <style>             nav a {                 display: inline-block;                 margin-right:-4px;                 background: green;                 color:white;                 font-weight:bold;                 text-decoration:none;             }             h1 {                 color:green;             }             body {                 text-align:center;             }         </style>     </head>     <body>         <h1>GeeksforGeeks</h1>         <h2>margin-right:-4px;</h2>         <nav>             <a href="#"> geeks </a>             <a href="#"> for </a>             <a href="#"> geeks </a>         </nav>     </body> </html>

输出结果如下:

2243fc2d0c46aeadaba0e2735b24673.png

支持的浏览器: CSS margin属性支持的浏览器如下所示:

Apple Safari 3.1

谷歌Chrome 4.0

Firefox 3.0

Opera 7.6

Internet Explorer 8.0