<div class="wrap">
<div class="logo">
<div class="logo_left">
<img src="images/logo.jpg" alt="慕课网"/>
</div>
<div class="logo_right">
<img src="images/tel.jpg" alt="服务热线"/>24小时服务热线:123-456-789
</div>
</div><!-- logo结束 -->
</div> <!-- wrap结束 -->
.wrap{width: 1000px;margin:0 auto;}
.logo{background: white;height: 80px;width: 1000px;}
.logo_left{width:200px;float: left;}
.logo_right{width:300px;float: right;}
父元素的居中是通过magin来实现的,margin属性默认是不被继承的
他是块级元素 margin居中的 这个不会继承
<!DOCTYPE HTML>
<html>
<head>
<title>企业网站</title>
<meta http-equiv="Content-Type" Content="text" charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/mu.css">
<script type="text/javascript" src="js/setHomeSetFav.js" charset="gb2312" ></script>
</head>
<body>
<div class="top">
<div class="top_content">
<ul>
<li><a href="#">联系我们</a></li>
<li><a href="#" onclick="AddFavorite(window.location,document.title)">设为收藏</a></li>
<li><a href="#" onclick="SetHome(window.location)">设为首页</a></li>
</ul>
</div>
</div> <!-- top结束 -->
<div class="no">
<div calss="wrap">
<div class="logo">
<div class="logo_left">
<img src="images/logo.jpg" alt="慕课网"/>
</div>
<div class="logo_right">
<img src="images/tel.jpg" alt="服务热线"/>24小时服务热线:123-456-789
</div>
</div><!-- logo结束 -->
</div> <!-- wrap结束 -->
</div>
</body>
</html>
*{
margin: 0;padding: 0;font-size: 12px;
}
body{
background: #f5f5f5
}
.top{
width: 100%;height: 27px;background:url("../images/top_bg.jpg")0 0 repeat-x;
}
.top_content{width:1000px;margin:0 auto;}
.top_content ul li{list-style-image:url("../images/li_bg.gif");float:right;width:70px;line-height: 27px;}
a{text-decoration: none;color: #8e8e8e}
a:hover{color: #900};
.wrap{clear:both;width: 1000px;margin:0 auto;}
.logo{background: white;height: 80px;}
.logo_left{width:200px;float: left;}
.logo_right{width:300px;float: right;}
.wrap{width: 1000px;margin: 0 auto;}
.logo{background: white;height: 80px;}
不好意思,原本应该是这样,上面贴的有错误。 logo无法继承父元素wrap的宽度