浮动 div 未正确浮动
这是我在这里发表的第一篇文章,因为我束手无策,所以我想我应该跳进去,最后寻求一些帮助!
我正在设计的网站上有一个“联系我们”部分,其中包含一个关于我们的小段落、电子邮件和电话。旁边有一个电子邮件联系表单,是我从 php 表单生成器获得的。一切都很顺利,直到我把那个坏男孩扔了进去。
这是我的“联系我们”“包装器”代码:
#contact {
background-image:url(img/contact_bg.jpg);
background-repeat: no-repeat;
width: 820px;
height: 459px;
margin: 25px 70px 50px 70px;
clear: both;
}
#thanks {
width: 324px;
height: 100px;
padding-top: 35px;
}
#thanks span {
font-size: 1.5em;
font-weight: normal;
font-style: italic;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
text-decoration: none;
padding: 0 0 0 25px;
}
#details {
width: 324px;
height: 63px;
padding-top: 25px;
clear: both;
}
#details span {
font-size: 1.115em;
font-weight: normal;
font-style: italic;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
text-decoration: none;
padding: 0 0 0 25px;
clear: both;
}
#about {
width: 324px;
clear: both;
}
#about h2 {
font-size: 1.618em;
font-weight: normal;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
padding-left: 25px;
text-decoration: none;
clear: both;
}
#about span {
font-size: 1em;
font-weight: normal;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
line-height: 14px;
text-decoration: none;
padding: 10px 0 0 25px;
clear: both;
}
这是我的表单 css:
#form {
margin:0 auto;
text-align:left;
width:391px;
height: 459px;
float: right;
}
form.appnitro {
margin:20px 20px 0;
padding:0 0 20px;
}
这是一些屏幕截图:
这就是它应该的样子: 这就是它现在的样子:(
非常感谢任何帮助,如果您需要更多信息,请告诉我 !
非常感谢
This is my first post here and as I am at my wits end so thought I'd jump in and finally ask for some help!
I have a "Contact us" section on a website I'm designing containing a small about us paragraph, email and phone. Next to it there is an email contact form that I got from php form builder. Everything was going swimmingly until I dropped that bad boy in.
Anywho here's my code for the Contact Us 'wrapper':
#contact {
background-image:url(img/contact_bg.jpg);
background-repeat: no-repeat;
width: 820px;
height: 459px;
margin: 25px 70px 50px 70px;
clear: both;
}
#thanks {
width: 324px;
height: 100px;
padding-top: 35px;
}
#thanks span {
font-size: 1.5em;
font-weight: normal;
font-style: italic;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
text-decoration: none;
padding: 0 0 0 25px;
}
#details {
width: 324px;
height: 63px;
padding-top: 25px;
clear: both;
}
#details span {
font-size: 1.115em;
font-weight: normal;
font-style: italic;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
text-decoration: none;
padding: 0 0 0 25px;
clear: both;
}
#about {
width: 324px;
clear: both;
}
#about h2 {
font-size: 1.618em;
font-weight: normal;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
padding-left: 25px;
text-decoration: none;
clear: both;
}
#about span {
font-size: 1em;
font-weight: normal;
letter-spacing:1px;
color: #ffffff;
text-shadow: 1px 1px 1px #000000;
line-height: 14px;
text-decoration: none;
padding: 10px 0 0 25px;
clear: both;
}
and here is my form css:
#form {
margin:0 auto;
text-align:left;
width:391px;
height: 459px;
float: right;
}
form.appnitro {
margin:20px 20px 0;
padding:0 0 20px;
}
Here are some screenshots:
This is what it's supposed to look like:
This is what its looking like now :(
Any help is greatly appreciated, if you require any more info please let me know.
Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
#thanks
和#about
都是浮动的,因此您的联系表单虽然是浮动的,但会显示在它们下方。您需要浮动#thanks
和#about
float:left
。您还有很多
clear:both
,这将重置文档流,可能会导致您遇到的一些问题。不过,如果没有看到实际的 HTML,就很难说。Your
#thanks
nor your#about
are floated so your contact form, though floated, is appearing under them. You need to float both#thanks
and#about
float:left
.You also have a lot of
clear:both
which will reset the document flow probably causing some of the issues you're seeing. It's hard to say without seeing the actual HTML though.您需要做的就是在左侧内容周围放置另一个 div 并将其向左浮动,就像这样
应该可以让我知道它是如何进行的;-)
All you need to do is put another div around the left hand content and float it left, like so
That should work let me know how it goes ;-)