gpt4 book ai didi

css - 右对齐 div(不是右屏幕边缘)

转载 作者:太空宇宙 更新时间:2023-11-03 23:43:39 25 4
gpt4 key购买 nike

我只是在学习,我正在尝试将我的 4 div 布局设置为我想要的页面大小(而不是用户窗口打开的任何大小)。基本问题,但我无法将右侧的 div 附加到左侧的 div,不一定是用户窗口的右侧。

这是我的代码,在此先感谢您。

HTML:

<!DOCTYPE html>
<html>
<head>
<title>all.about.me</title>
<link rel='stylesheet' type='text/css' href='me_stylesheet.css'/>
</head>
<body>
<div id="header">
<p>March 02, 2014
<br><br>Hello.
<br>
</p>
</div>
<div id="left"> </div>
</div>
<div id="right"> </div>
<div id="footer">
</a>
</div>
</body>
</html>

CSS:

p
{
font:10px verdana,sans-serif;
color: white;
padding-left: 10px;
padding-right: 5px;
padding-top: 5px;
padding-bottom: 5px;
}

body
{
background-color: red;
}

div {
border-radius: 0px;
}

#header {
height: 80px;
width: 600px;
background-color: black;
margin-bottom: 5px;
}

#footer {
height: 35px;
width: 600px;
background-color: black;
margin-bottom: 5px;
clear: both;
}


#left {
height: 385px;
width: 122px;
background-color: black;
float: left;
margin-right: 5px;
margin-bottom: 5px;
}

#right {
height: 385px;
width: 300px;
background-color: black;
float: right;
margin-right: 5px;
margin-bottom: 5px;
}

我知道这是一个基本问题,我可能可以在 Google 上找到答案,但你们这里的编码人员总是有不同且独特的做事方式,这确实能激发创造性编码。感谢您的帮助。

最佳答案

我建议您在 .left.right 上都使用 float: left。这会将右侧的 div 放置在左侧 div 的右侧。

http://jsfiddle.net/AB2VE/1/

关于css - 右对齐 div(不是右屏幕边缘),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22142311/

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