我有两个属于同一类的标签。这是我的这个类的CSS:
.required
{
background-image:url(/img/required.png);
background-position: right;
background-repeat:no-repeat;
padding-right:10px;
}
在所有浏览器中,两个元素的右上角都有红星。但在 IE 7 中只有第一个元素有这个星号。我做错了什么?请帮助我。
最佳答案
@Alexander.Plutov:使用 required.png
我 borrowed 对于练习,以下代码示例似乎工作正常(我只是将您的 CSS
规则压缩为简写版本):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.required
{
background: url(img/required.png) no-repeat right top;
padding-right: 15px;
}
</style>
</head>
<body>
<form action="4430474.htm" method="post">
<div>
<label for="field1" class="required">Field 1:</label>
<input type="text" name="field1" id="field1" size="40" />
</div>
<div>
<label for="field2" class="required">Field 2:</label>
<input type="text" name="field2" id="field2" size="40" />
</div>
</form>
</body>
</html>
您是否对表单中的任何内容使用了任何float
或position
规则?这些通常是 IE6/7 中行为不端的地方。
关于html - IE7 奇怪的背景位置行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4430474/