gpt4 book ai didi

html - sub div css 格式化问题?

转载 作者:行者123 更新时间:2023-11-28 18:57:53 24 4
gpt4 key购买 nike

我有这个简单的布局 css,它提供 3 行布局CSS代码

<style type="text/css">  
body {
width:750px;
margin:0 auto;
margin-top:30px;
}



/* ----- HEADER ----- */



#header {
width:750px;
height:150px;
background-color:#333333;
}



/* ----- MAIN CONTENT ----- */



#content {
width:750px;
background-color:#333333;
margin-top:10px;
min-height:500px; /* for modern browsers */
height:auto !important; /* for modern browsers */
height:500px; /* for IE5.x and IE6 */
}



/* ----- FOOTER ----- */



#footer {
width:750px;
height:100px;
background-color:#333333;
margin-top:10px;
}
</style>

这是html代码

<!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=iso-8859-1" />
<title>example page</title>
</head>
<body>
<div id="header">
</div>
<div id="content">
</div>
<div id="footer">
</div>
</body>
</html>

我需要做的是在标题 div 中创建的每个 div 必须具有向左浮动的格式

<div id="header"><div>welcome</div></div>

例如这个 div have welcome 必须有 float left 格式而不传递任何类或 id

最佳答案

要直接回答您的问题,您可以:

#header div { float: left; }

但是为什么?不能用span代替div吗?如果您不需要 id 或 class 标签,为什么还要任何标签?

关于html - sub div css 格式化问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7212396/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com