GVKun编程网logo

css怎样去除按钮之间的间距(css怎样去除按钮之间的间距和颜色)

10

在本文中,我们将详细介绍css怎样去除按钮之间的间距的各个方面,并为您提供关于css怎样去除按钮之间的间距和颜色的相关解答,同时,我们也将为您带来关于css–Bootstrap3按钮之间的空间、css

在本文中,我们将详细介绍css怎样去除按钮之间的间距的各个方面,并为您提供关于css怎样去除按钮之间的间距和颜色的相关解答,同时,我们也将为您带来关于css – Bootstrap 3按钮之间的空间、css – Bootstrap 4按钮示例:按钮之间的空间来自哪里?、css – flexbox项目之间的间距、css – thead和tbody之间的间距的有用知识。

本文目录一览:

css怎样去除按钮之间的间距(css怎样去除按钮之间的间距和颜色)

css怎样去除按钮之间的间距(css怎样去除按钮之间的间距和颜色)

在css中,可以利用“font-size”属性去除按钮之间的间距,按钮之间有间距是因为元素节点有文本节点,在缩进代码时会占据宽度,只需要给按钮元素的父元素添加“font-size:0;”样式即可去除间距。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

css怎样去除按钮之间的间距

正常情况下,当我们设置了按钮之后,按钮之间会出现间距,示例如下:

<!DOCTYPE html>
<html lang=en>
<head>
    <Meta charset=UTF-8>
    <Meta name=viewport content=width=device-width, initial-scale=1.0>
    <Meta http-equiv=X-UA-Compatible content=ie=edge>
    <title>Document</title>
</head>
<body>
    <button>按钮</button>
    <button>按钮</button>
    <button>按钮</button>
</body>
</html>

输出结果:

09.png

这时候我们是需要设置按钮元素的父元素,给其父元素添加“font-size:0;”样式即可。

示例如下:

<!DOCTYPE html>
<html lang=en>
<head>
    <Meta charset=UTF-8>
    <Meta name=viewport content=width=device-width, initial-scale=1.0>
    <Meta http-equiv=X-UA-Compatible content=ie=edge>
    <title>Document</title>
    <style>
    body{
font-size:0;
}
</style>
</head>
<body>
    <button>按钮</button>
    <button>按钮</button>
    <button>按钮</button>
</body>
</html>

输出结果:

10.png

<!DOCTYPE html>
<html lang=en>
<head>
    <Meta charset=UTF-8>
    <Meta name=viewport content=width=device-width, initial-scale=1.0>
    <Meta http-equiv=X-UA-Compatible content=ie=edge>
    <title>Document</title>
    <style>
    div{
        font-size:0;
        width:200px;
        height:100px;
        border:1px solid red;
}
</style>
</head>
<body>
    <div>
    <button>按钮</button>
    <button>按钮</button>
    <button>按钮</button>
    </div>
</body>
</html>

输出结果:

11.png

(学习视频分享:css视频教程)

css – Bootstrap 3按钮之间的空间

css – Bootstrap 3按钮之间的空间

如果我连续放几个Bootstrap 3按钮:

    

它们之间有一个小空间.它来自哪里以及如何在不使用浮动的情况下将其移除?根据Firebug和Chrome Inspector,按钮没有应用任何边距.

最佳答案
按钮之间的换行符实际上会占用空间.注意:

如果您希望按钮可视化分组,则可以使用按钮组规则:http://getbootstrap.com/components/#btn-groups

css – Bootstrap 4按钮示例:按钮之间的空间来自哪里?

css – Bootstrap 4按钮示例:按钮之间的空间来自哪里?

参见英文答案 > Two inline-block elements,each 50% wide,do not fit side by side in a single row                                    7个
我试图检查Bootstrap 4中的“按钮”示例.它们有一个看起来很漂亮的按钮,如下所示:

enter image description here

http://getbootstrap.com/docs/4.0/components/buttons/

但我不明白,按钮之间的空间来自哪里.

enter image description here

这不是边距,不是柔性框对齐,不是透明边框.
那么,它是如何工作的?实际上,我禁用了dev-tools中的所有样式,但该空间并没有消失.

解决方法

空间就在那里,因为HTML元素之间有空格.如果删除空格,则按钮将彼此相邻.

请注意,元素之间的空格(换行符)由浏览器压缩到单个空格.

< button type =“button”class =“btn btn-primary”> Primary< / button>
< button type =“button”class =“btn btn-secondary”> Secondary< / button>

Buttons with spacing between them

现在,如果我们删除空格:

< button type =“button”class =“btn btn-primary”> Primary< / button>< button type =“button”class =“btn btn-secondary”> Secondary< / button>

enter image description here

css – flexbox项目之间的间距

css – flexbox项目之间的间距

这是我想要的:

The closest I’ve got.在flexBox项目上应用余量,然后从第一个&最后的孩子。

问题是:第一个孩子并不总是第一个在视觉上,因为我可以改变布局顺序(example)。

在使用保证金时,是否有一种方法来考虑视觉顺序?

解决方法

您可以尝试为所有框设置相同的边距,然后在容器上还原此边距:

所以替换这个:

.flex > * { margin: 0 10px; }    
.flex > :first-child { margin-left: 0; }
.flex > :last-child { margin-right: 0; }

.flex.vertical > :first-child { margin-top: 0; }
.flex.vertical > :last-child { margin-bottom: 0; }

有了这个:

.flex.vertical { margin: -20px 0 0 -20px; }
.flex > * { margin: 0 0 0 20px; }
.flex.vertical > * { margin: 20px 0 0 0; }

css – thead和tbody之间的间距

css – thead和tbody之间的间距

我有一个简单的html表,像这样:
<table>
  <thead>
    <tr><th>Column 1</th><th>Column 2</th></tr>
  </thead>
  <tbody>
    <trhttps://www.jb51.cc/tag/irs/" target="_blank">irst-row"><td>Value 1</td><td>Value 2</td></tr>
    <tr><td>Value 3</td><td>Value 4</td></tr>
    <tr><td>Value 5</td><td>Value 6</td></tr>
    <tr><td>Value 7</td><td>Value 8</td></tr>
  </tbody>
</table>

我想用下面的方式来设计它:

>带有阴影的标题行
>标题行和第一个正文行之间的空格

我尝试了不同的事情:

table {
    /* collapsed,because the bottom shadow on thead tr is hidden otherwise */
    border-collapse: collapse;
}
/* Shadow on the header row*/
thead tr   { Box-shadow: 0 1px 10px #000000; }
/* Background colors defined on table cells */
th         { background-color: #ccc; }
tr.even td { background-color: yellow; }
tr.odd td  { background-color: orange; }

/* I would like spacing between thead tr and tr.first-row */

tr.first-row {
    /* This doesn't work because of border-collapse */
    /*border-top: 2em solid white;*/
}

tr.first-row td {
    /* This doesn't work because of border-collapse */
    /*border-top: 2em solid white;*/
    /* This doesn't work because of the td background-color */
    /*padding-top: 2em;*/
    /* Margin is not a valid property on table cells */
    /*margin-top: 2em;*/
}

参见:http://labcss.net/#8AVUF

有没有人有任何tipps如何我可以这样做?或实现相同的视觉效果(即身体阴影间距)?

谢谢!

解决方法

我认为我有这个 fiddle和我更新 yours:
tbody:before {
    content: "-";
    display: block;
    line-height: 1em;
    color: transparent;
}

关于css怎样去除按钮之间的间距css怎样去除按钮之间的间距和颜色的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于css – Bootstrap 3按钮之间的空间、css – Bootstrap 4按钮示例:按钮之间的空间来自哪里?、css – flexbox项目之间的间距、css – thead和tbody之间的间距的相关信息,请在本站寻找。

本文标签: