Style 3输入彼此相同

时间:2015-04-24 07:34:07

标签: html css

我有一个表单,我有一个“+”按钮,文本输入和“ - ”按钮,如下图所示。我有一个问题,因为我无法将其设置为在所有浏览器上的图片上看起来像它。

预期:expected style

这就是它在我的页面上的显示方式:

Chrome 上显示:enter image description here然后开启 Safari enter image description here等等 资源管理器enter image description here

这是CSS代码:

.qty {
  width: 34px;
  height: 20px;
  text-align: center;
  display: block;
}
input.qtyplus {
  padding-top: 4px;
  width: 34px;
  height: 20px;
  border-bottom: 2px solid #ff6100;
  border-left: 2px solid #ff6100;
  border-right: 2px solid #ff6100;
  border-top: 2px black;
  background: black;
  color: #ff6100;
  font-weight: bold;
  border-radius: 0 0 4px 4px
}
input.qtyminus {
  width: 34px;
  height: 20px;
  border-top: 2px solid #ff6100;
  border-left: 2px solid #ff6100;
  border-right: 2px solid #ff6100;
  border-bottom: 2px black;
  background: black;
  color: #ff6100;
  font-weight: bold;
  border-radius: 4px 4px 0 0;
}
input[type=text] {
  background: black;
  color: white;
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  font-weight: bold;
  border-left: 2px solid #ff6100;
  border-right: 2px solid #ff6100;
  border-top: 2px black;
  border-bottom: 2px black;
  height: 20px;
  width: 28px;
  margin-top: -1px;
}
<input type='button' value='-' class='qtyminus' field='quantity' />
<input type='text' name='quantity' value='0' class='qty' readonly />
<input type='button' value='+' class='qtyplus' field='quantity' />

2 个答案:

答案 0 :(得分:0)

这有效

.qty {
  background: none repeat scroll 0 0 black;
  border-width: 2px;
  font-weight: bold;
  height: 20px;
  width: 34px;
  cursor: pointer;
}

input.minus {
  border-color: #ff6100 #ff6100 black;
  border-radius: 4px 4px 0 0;
  border-style: solid solid none;
  color: #ff6100;
}

input.plus {
  border-color: black #ff6100 #ff6100;
  border-radius: 0 0 4px 4px;
  border-style: none solid solid;
  color: #ff6100;
  padding-top: 4px;
}

input.num {
  border-color: black #ff6100;
  border-style: none solid;
  color: white;
  display: block;
  font-family: "Open Sans",sans-serif;
  font-size: 15px;
  margin-top: -1px;
  pointer-events: none;
}

text =&gt;按钮,班级已更改

<input type='button' value='-' class='qty minus' field='quantity' />
<input type='button' name='quantity' value='0' class='qty num' readonly />
<input type='button' value='+' class='qty plus' field='quantity' />

答案 1 :(得分:0)

这似乎适用于Firefox,IE和Chrome。

这是一个小例子:http://jsfiddle.net/rucaj2cr/10/

HTML

<input type='button' value='-' class='qty qtyminus' field='quantity' />
<input type='text' name='quantity' value='0' class='qty' readonly />
<input type='button' value='+' class='qty qtyplus' field='quantity' />

CSS

.qty {
  height: 20px;
  text-align: center;
  display: block;
  border-left: 2px solid #ff6100;
  border-right: 2px solid #ff6100;
  background: black;
  font-weight: bold;
  padding: 0;
  margin: 0;
}

input.qtyplus {
  border-bottom: 2px solid #ff6100;
  border-top: 2px black;
  color: #ff6100;
  border-radius: 0 0 4px 4px;
  width: 34px;
}

input.qtyminus {
  border-top: 2px solid #ff6100;
  border-bottom: 2px black;
  color: #ff6100;
  border-radius: 4px 4px 0 0;
  width: 34px;
}

input[type=text] {
  color: white;
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  border-top: 2px black;
  border-bottom: 2px black;
  margin-top: -1px;
  width: 30px;
}