css样式定心在Safari
答
这取决于你想要的风格。您可能试图将块级元素居中放置,如DIV或UL。在这种情况下,你使用中心
div {
margin-left:auto;
margin-right:auto;
padding-left:<some fixed size>;
padding-right:<some fixed size>;
width:<some fixed size>;
}
答
居中的文字内容据我所知没有具体的浏览器/文档类型的问题。所以它看起来像你试图集中别的东西而不是文本。如果您确实想要将块元素居中,请给它一个固定的width
(以像素为单位),并在其上应用margin: 0 auto;
。
下面是一个SSCCE
<!doctype html>
<html lang="en">
<head>
<title>SO question 1897444</title>
<style>
#center {
margin: 0 auto; /* top and bottom 0, left and right expanding. */
width: 300px; /* Required to have a reference point to center. */
border: 1px solid black; /* Not required, just presentational. */
}
</style>
</head>
<body>
<div id="center">Centered block element</div>
</body>
</html>
不过,这不会怪癖模式在IE浏览器。只要确保你使用的是strict doctype即可。
答
我得到了我所做的代码点:
width: 190px;
padding-left:23px;
height: auto;
text-align: left;
line-height: 18px;
和现在 感谢工作都在努力帮助我
*轻笑* craptastic。 – CodeMonkey 2009-12-13 20:27:08