HTML2列布局-在顶级容器中应用背景色
我正试图用我的html创建一个2列的布局,但这并没有发生。这是我的密码:HTML2列布局-在顶级容器中应用背景色,html,css,Html,Css,我正试图用我的html创建一个2列的布局,但这并没有发生。这是我的密码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Welcome</title>
<style>
body {
margin: 0;
padding: 0;
width: 100%;
color: black;
font: normal 12px/1.8em Arial, Helvetica, sans-serif;
background-color: #132959;
background-repeat: repeat;
background-position: left top;
}
.outer{
width:970px;
margin: 0 auto;
background: black;
}
.toc{
width:250px;
margin: 0;
padding:0;
float:left;
color:yellow;
}
.content{
padding: 0;
width:720px;
float:right;
color:white;
}
.container{
width:970px;
margin: 20px auto;
}
.logo {
margin: 0;
padding: 0;
float: left;
width: auto;
}
.logo a{
color : #fff;
text-decoration:none;
font: bold 40px/1.2em Arial, Helvetica, sans-serif;
letter-spacing: -2px;
}
.logo small {
display: block;
padding-left: 80px;
font: normal 12px/1.2em Arial, Helvetica, sans-serif;
color: #EDF3F6;
letter-spacing: normal;
}
.logoimage {
height: 50px;
border: none;
margin: 0;
}
</style>
</head>
<body>
<div class="container">
<div class="logo">
<a href="http://www.csmart.co.in">Csmart
<small>Let's make life easy!</small> </a>
</div>
<div style="clear:both;padding:15px"/>
<div class="outer">
<div class="toc">
TOC
</div>
<div class="content">
Welcome
</div><!-- content -->
</div><!-- outer-->
</div>
欢迎
身体{
保证金:0;
填充:0;
宽度:100%;
颜色:黑色;
字体:标准12px/1.8em Arial,Helvetica,无衬线;
背景色:#132959;
背景重复:重复;
背景位置:左上;
}
.外部{
宽度:970px;
保证金:0自动;
背景:黑色;
}
.toc{
宽度:250px;
保证金:0;
填充:0;
浮动:左;
颜色:黄色;
}
.内容{
填充:0;
宽度:720px;
浮动:对;
颜色:白色;
}
.集装箱{
宽度:970px;
保证金:20px自动;
}
.标志{
保证金:0;
填充:0;
浮动:左;
宽度:自动;
}
.标志a{
颜色:#fff;
文字装饰:无;
字体:粗体40px/1.2em Arial,Helvetica,无衬线;
字母间距:-2px;
}
.标志小{
显示:块;
左侧填充:80px;
字体:标准12px/1.2em Arial,Helvetica,无衬线;
颜色:#EDF3F6;
字母间距:正常;
}
.logoimage{
高度:50px;
边界:无;
保证金:0;
}
TOC
欢迎
我的潜水器外壳是黑色的。但它不会显示在屏幕上。如果我给外边一个高度。。然后它出现了。但不一定要这样。。我无法预测这一页的高度。为什么div outer的背景色不显示在浏览器上 添加溢出:隐藏到你的外部。就像我做的这把小提琴:
我建议您在页面的css部分编写所有css代码,否则会变得非常混乱 因为你的内在内容是浮动的。将
放在.outer
div的末尾,您将看到它
代码:所有内部元素都是浮动的,因此没有高度。您需要取消其中一个内部元素的浮动,为容器元素提供一个高度,或者在
外部
元素之后添加一个清除div