62,244
社区成员




<div id="header" class="header" runat="server">
<div id="logo" runat="server" class="logo">
</div>
<div class="title">
<asp:Label ID="lblMsg" runat="server" Font-Bold="true" ForeColor="Red"></asp:Label>
<pu:Language ID="lng" runat="server" />
</div>
</div>
.header { width: 100%; height: 70px; background-image: url(Images/header-bg.gif); }
.header .logo {width:100%; height: 70px; float:left; background: url(Images/logo.gif) no-repeat; }
.header .title { margin-left: 220px; height: 70px; background: url(Images/header.gif) no-repeat; text-align: right; }
<style type="text/css">
*{margin:0; padding:0;}
.cl{clear:both;}
.header{width:100%; height: 70px; background-color:#CCC; padding:10px;}
.header .logo{ float:left; width:300px;background-color:#09F;height: 70px; color:#FFF;}
.header .title{float:left; width:400px;background-color:#999;height: 70px;}
</style>
</head>
<body>
<div class="header">
<div class="logo">
LOGO width:100%;这种设置,想要实现你想要的效果,显然不可取,
最好设置个具体宽度,而且你要知道.logo 和.title的宽度和不超过.heade宽度
<br />看来你没明白width:100%;怎么用.
logo的width:100%;,等于logo的宽度跟header一样了
</div>
<div class="title">
.logo 要float:left;而且.title也要float:left;
</div>
</div>
</body>
.header { width: 100%; height: 70px; background-image: url(Images/header-bg.gif); }
.header .logo {max-width:100px; height: 70px; float:left; background: url(Images/logo.gif) no-repeat; }
.header .title { margin-left: 220px; width:200px; float:left; height: 70px; background: url(Images/header.gif) no-repeat; text-align: right; }
设定logo的最大宽度,然后设定title的宽度,设置左浮动就行。
.header { width: 100%; height: 70px; background-image: url(Images/header-bg.gif); }
.header .logo { height: 70px; float:left; background: url(Images/logo.gif) no-repeat; }
.header .title { margin-left: 220px; height: 70px; background: url(Images/header.gif) no-repeat; text-align: right; float:left }
<div id="header" class="header" runat="server">
<div id="dv_body" style="width:900px; height:72px;">
<div id="logo" runat="server" class="logo">
adfadfadf
</div>
<div class="title" id="title">
<asp:Label ID="lblMsg" runat="server" Font-Bold="true" ForeColor="Red"></asp:Label>
<pu:Language ID="lng" runat="server" />
</div>
</div>
</div>
<script>
document.getElementById("dv_body").style.width= (document.getElementById("logo").offsetWidth + document.getElementById("title").offsetWidth + 20) +"px";
alert(document.getElementById("dv_body").style.width);
</script>
.header { width: 100%; overflow:hidden; height: 70px; background-image: url(Images/header-bg.gif); }
.header .logo {width:auto; min-width:220px; height: 70px; float:left; background: url(Images/logo.gif) no-repeat; border:1px #000000 solid; }
.header .title { margin-left: 220px; height: 70px; background: url(Images/header.gif) no-repeat; text-align: right;border:1px #000000 solid; }
.header { width: 100%; height: 70px; background-image: url(Images/header-bg.gif); border:1px solid #000 }
.header .logo {height: 70px; float:left; background: url(Images/logo.gif) no-repeat; border:1px solid #f60 }
.header .title { margin-left: 220px; height: 70px; background: url(Images/header.gif) no-repeat; text-align: right; border:1px solid #999; float:left}