【问题标题】:Why is there a white space between my button and its border?为什么我的按钮和它的边框之间有一个空白?
【发布时间】:2019-02-03 15:06:08
【问题描述】:

网络应用

sn-p

我在 Chrome 中遇到了按钮高度问题。它在 Firefox 中工作得很好,但是虽然我将它设置为 100%,但它并没有填满整个高度。这对我来说没有多大意义,所以有人可以向我解释一下吗?

它似乎在sn-p中工作?我 100% 不使用 JavaScript 来设置这些:纯粹是我在下面列出的 CSS。

直到今天才成为问题……这太奇怪了。

body {
 background-color: dimgrey;
 margin: 0;
 padding: 0;
}
.topbar {
  border-radius: 0px;
  border-bottom: 1px lightgrey solid;
  margin-bottom: 0px;
  background-color: white;
  max-width: calc(80%-1px);
  height: 60px;
  max-height: 60px;
  text-align: right;
  display: flex;
}
.login-button {
  max-width: 15%;
  min-width: 15%;
  background-color: tomato;
  border: none;
  border-left: 1px lightgrey solid;
  login_text: 'color';
  color: white;
  outline: none;
  cursor: pointer;
  font-size: 30px;
  height: 100%;
}
.e-mess {
  width: 85%;
  height: 100%;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
}
<div class='topbar'>
  <div class='e-mess'></div>
  <button class='login-button'>login</button>
</div>

【问题讨论】:

  • 是topbar的边框底部
  • 是的,但是如果你运行它,它可以在 sn-p 中工作
  • 它不应该是白色的......它是 css 中列出的浅灰色
  • 所以涉及的 CSS 更多
  • 不...不适合顶部栏...这就是全部...减去一些文本颜色样式dev.orderonlinellc.com如果您想玩它,就有这个应用程序...它超级棒烦人...就像.5px 关闭一样,这没有意义-_-

标签: html css google-chrome height margins


【解决方案1】:

我不确定为什么会出现这个问题,但我必须为 topbar 类设置 min-height 属性。

.topbar {
  border-radius: 0px;
  border-bottom: 1px lightgrey solid;
  margin-bottom: 0px;
  background-color: white;
  max-width: calc(80%-1px);
  min-height: 60px;
  height: 60px;
  max-height: 60px;
  text-align: right;
  display: flex;
}

【讨论】:

  • 你应该从 css 中删除 login-text:'color',因为这会导致你的 css 出错(因为没有名为 login_text 的原生 css 属性)也尽量避免使用颜色名称,改用十六进制代码(dimgrey 应该是#696969 或 Dimgray(带有 a)。登录按钮上的空 div html 可能正在创建一个空间,您可以通过使用以下边距来解决它 - 1,但建议整体上更好的 css..