html - 如何不让文字覆盖按钮?

标签 html css button input

我在网上找到了这个例子。它可以修复以使文本不在按钮上方吗?不是通过符号限制,而是在视觉上限制。

现在它看起来像这样:

enter image description here

我想这个

enter image description here

这可能吗?我想使用这个模板,但我没有修复它的经验。模板最初有这样的错误。我没有改变任何东西。 Original .

在此先感谢您的帮助!

:root {
  background: #f5f6fa;
  color: #9c9c9c;
  font: 1rem "PT Sans", sans-serif;
}

html,
body,
.container {
  height: 100%;
}

a {
  color: inherit;
}
a:hover {
  color: #7f8ff4;
}

.container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
}

.uppercase {
  text-transform: uppercase;
}

.btn {
  display: inline-block;
  background: transparent;
  color: inherit;
  font: inherit;
  border: 0;
  outline: 0;
  padding: 0;
  -webkit-transition: all 200ms ease-in;
  transition: all 200ms ease-in;
  cursor: pointer;
}
.btn--primary {
  background: #7f8ff4;
  color: #fff;
  box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  padding: 12px 36px;
}
.btn--primary:hover {
  background: #6c7ff2;
}
.btn--primary:active {
  background: #7f8ff4;
  box-shadow: inset 0 0 10px 2px rgba(0, 0, 0, 0.2);
}
.btn--inside {
  margin-left: -96px;
}

.form__field {
  width: 500px;
  background: #fff;
  color: #a3a3a3;
  font: inherit;
  box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.1);
  border: 0;
  outline: 0;
  padding: 22px 18px;
}
<div class="container">
	<div class="container__item">
		<form class="form">
			<input type="email" class="form__field" placeholder="Your E-Mail Address" />
			<button type="button" class="btn btn--primary btn--inside uppercase">Send</button>
		</form>
	</div>
</div>

最佳答案

你可以尝试“padding-right”作为输入

:root {
  background: #f5f6fa;
  color: #9c9c9c;
  font: 1rem "PT Sans", sans-serif;
}

html,
body,
.container {
  height: 100%;
}

a {
  color: inherit;
}
a:hover {
  color: #7f8ff4;
}

.container {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
}

.uppercase {
  text-transform: uppercase;
}

.btn {
  display: inline-block;
  background: transparent;
  color: inherit;
  font: inherit;
  border: 0;
  outline: 0;
  padding: 0;
  -webkit-transition: all 200ms ease-in;
  transition: all 200ms ease-in;
  cursor: pointer;
}
.btn--primary {
  background: #7f8ff4;
  color: #fff;
  box-shadow: 0 0 10px 2px rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  padding: 12px 36px;
}
.btn--primary:hover {
  background: #6c7ff2;
}
.btn--primary:active {
  background: #7f8ff4;
  box-shadow: inset 0 0 10px 2px rgba(0, 0, 0, 0.2);
}
.btn--inside {
  margin-left: -96px;
}

.form__field {
  width: 500px;
  background: #fff;
  color: #a3a3a3;
  font: inherit;
  box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.1);
  border: 0;
  outline: 0;
  padding: 22px 18px;
  padding-right:100px;
  box-sizing: border-box;
}
<div class="container">
	<div class="container__item">
		<form class="form">
			<input type="email" class="form__field" placeholder="Your E-Mail Address" />
			<button type="button" class="btn btn--primary btn--inside uppercase">Send</button>
		</form>
	</div>
</div>

关于html - 如何不让文字覆盖按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57463851/

相关文章:

html - CSS 使图像在图像上居中

javascript - 使用 CSS 将文本拉到前面(或将图像拉到后面)和使用 javascript 随机选择的图像

java - 使用自定义 ListView 布局中的按钮增加 Int 的值

javascript - 带有 iFrame 的后退按钮

html - 字体简写的奇怪 CSS 行为

html - 如何使用此模板搜索按钮代替表单中的提交按钮?

用于更改表单边框颜色的 Javascript 不起作用?

html - CSS 进度条错误

javascript - 在事件的 div 上(使用 JQuery),如何将其他 div 彼此分开?

jquery - jsgrid 多个自定义控制按钮?