如何让“x”停留在所有支持浏览器的圆圈中间(至少是firefox3 +和chrome)
段:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Backbone: Tody</title>
<style>
.delete {
-moz-border-radius: .75em;
-webkit-border-radius: .75em;
width: 1.4em;
height: 1.4em;
text-align: center;
display: inline-block;
line-height: 1.4em;
display:inline-block
vertical-align:middle
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
font-weight: bold;
color: white;
background-color: gray;
cursor: pointer;
}
.delete:before {
content: "\2715";
/* content: "\00D7"; */
}
.delete:hover {
background-color: red;
}
</style>
</head>
<body>
<div class="delete"></div>
</body>
</html>
答案 0 :(得分:0)
如果您希望它在浏览器中完美匹配,那么最好的选择可能是使用图像 - 定位x将取决于不同浏览器中的默认字体大小。
那就是说,我说它在OS X上的FF4b和Chrome 7已足够接近......
答案 1 :(得分:0)
我通过设置这样的边距并使内部空间(框+填充)与字体大小相同来实现此功能。 http://jsbin.com/unera3/5/edit
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Backbone: Tody</title>
<style>
.delete {
-moz-border-radius: .75em;
-webkit-border-radius: .75em;
width: 1.4em;
height: 1.4em;
text-align: center;
line-height: 1.4em;
vertical-align:middle
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
font-weight: bold;
color: white;
background-color: gray;
cursor: pointer;
}
.delete:before {
content: "\2715";
/* content: "\00D7"; */
}
.delete:hover {
background-color: red;
}
</style>
</head>
<body>
<div class="delete"></div>
</body>
</html>