html - 如何在一行中放置两个带边距的文本字段?

标签 html css

我试图通过在 .inline 类中应用 float: left; 属性,将两个输入字段放在一行中。

但是,因为所有 input[type="text"] 都有一个 margin: 5px;,它只适用于 width: 50% 仅当我删除边距时。

边距为 5:

Image 1

没有任何边距:

enter image description here

什么是理想的解决方案?

这是代码笔链接:http://codepen.io/biskotaki/pen/YXdYYE?editors=110

最佳答案

input[type="text"]
{
  box-sizing: border-box;
  padding: 5px;
  width: 100%;
}

.inline input {
  float: left;
  width: calc(50% - 10px);
  margin:5px;
}

http://fiddle.jshell.net/fL0gm3h9/

关于html - 如何在一行中放置两个带边距的文本字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31772707/

相关文章:

html - 背景图片不会在 IE 8 上显示

html - 哪些 DOM 元素不能接受 id?

html - 指针光标不显示

javascript - 使用 Html2Canvas 的文本区域屏幕截图

javascript - 使用 Javascript 暂时增加元素的宽度和高度,同时保持其居中位置

html - 防止:hover styles affecting :after content

html - contenteditable 中的光标在 Chrome 中无法正常运行

html - 将 div 放置在屏幕中央的 CSS 布局

css - 浏览器只加载一种字体

javascript - 如何在输入标签旁边附加div