我试图让我的徽标居中,但它总是在中心线的右边。我是CSS的新手,已经在谷歌上搜索了一个多小时的解决方案,但没有成功,下面是我的代码:
#Container{
width: 100%;
}
#logo{
display: block;
position: relative;
width: 200px;
margin: 0 auto;
}
#col{
width: 170px;
float: left;
}HTML
<!DOCTYPE html>
<html>
<head>
<title>tesing/title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="CLL1.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="logo"><img src="images/Logo.jpg"/></div>
<div id="Container">
<div id="col">
<select name="thing">
<option value=0>Category
</select>
<select name="model">
<option>Sub Category</option>
</select>
<select name="color">
<option>Sub Sub Category</option>
</select>
</div>
</div>
</body>
</html>发布于 2012-11-06 13:22:51
发布于 2012-11-06 13:05:14
你的CSS将会很好地居中#logo目录。如果它看起来仍然关闭,请确保徽标在您的实际200px宽的图像的中心。
另一种居中方法(使用绝对定位):
#logo {
width:200px;
position:absolute;
top:0;
left:50%;
margin-left:-100px; /* negative half of total width */
}如果你需要绝对定位,这只是另一种居中的方法。否则,您的margin:0 auto将正常工作。但也要确保你的徽标在你的logo.jpg的中心
发布于 2012-11-06 13:20:10
尝试此#logo{ text-align:center;}
https://stackoverflow.com/questions/13243985
复制相似问题