我在列表中有一个提交按钮:
<ul>
<li><input type="submit" value="Pls don't shift" /></li>
</ul>
li和输入具有不同的背景,并且这些背景应该是可定位的。
输入应具有动态宽度(取决于值)。
输入的值应几乎在输入的底部。
这些事情减少了解决问题的机会。
而问题恰恰是:IE8和IE9转移值的文本,而IE8也转移背景。
我试图解决它,并使其成为CSS(这只是一个'debug-css'):
li {
display: block;
width: auto;
border: 1px solid red;
padding: 0;
margin: 0;
float: left;
overflow: hidden;
}
input,
input:active:hover {
display: block;
background: url(tools-48x48.png) no-repeat center center;
width: auto;
height: 60px;
border: 1px solid transparent;
outline: none;
color: #fff;
text-align: center;
position: relative;
overflow: visble;
padding: 0 10px;
margin: 2px;
}
input:active:hover {
border: 1px solid red;
}
最有趣的是:现在,如果我单击按钮的文本值,那么它也会发生同样的移位,但是如果我单击eslewhere(在按钮上,但不在文本值上),那么它将起作用。
那就是我想在这里写的重点。
如何禁用提交按钮:IE中的活动状态?
谢谢!
最佳答案
我已经在IE9中对此进行了测试,当我删除了“不用”使用的几种样式时,单击它们不会改变输入文本。
删除的样式:
li {
width: auto;
border: 1px solid red;
padding: 0;
margin: 0;
overflow: hidden;
}
input,
input:active:hover{
background: url(tools-48x48.png) no-repeat center center;
outline:none;
}
并添加样式
input,
input:active:hover{
position: relative;
overflow: visible;
}
有关更多详细信息,请参见我的小提琴:http://jsfiddle.net/f67Vw/4/
另一个不错的选择似乎是将其替换为精心设计的
a
元素。的HTML
<ul>
<li>
<a href="#" class="button">Doesn't shift</a>
</li>
</ul>
的CSS
.button {
display: block;
width: auto;
height: 19px;
border: 1px solid transparent;
color: #000;
text-align: center;
padding: 20px 10px;
margin: 2px;
text-decoration:none;
}
再次在这里查看我的小提琴以获取更多详细信息:http://jsfiddle.net/f67Vw/4/
关于css - CSS:即移动按钮的文本值和背景,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7875794/