浮动 div 未正确浮动

发布于 2024-12-26 08:30:56 字数 1812 浏览 1 评论 0原文

这是我在这里发表的第一篇文章,因为我束手无策,所以我想我应该跳进去,最后寻求一些帮助!

我正在设计的网站上有一个“联系我们”部分,其中包含一个关于我们的小段落、电子邮件和电话。旁边有一个电子邮件联系表单,是我从 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;
   }

这是一些屏幕截图:

这就是它应该的样子: 预期 这就是它现在的样子:( actual

非常感谢任何帮助,如果您需要更多信息,请告诉我 !

非常感谢

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: expected
This is what its looking like now :( actual

Any help is greatly appreciated, if you require any more info please let me know.

Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏末染殇 2025-01-02 08:30:56

您的 #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.

热情消退 2025-01-02 08:30:56

您需要做的就是在左侧内容周围放置另一个 div 并将其向左浮动,就像这样

<div style="float:left">
    <div id="thanks">
        <span>Thank you for your interest in Dan James construction. Please contact us using a method convenient for you.</span>
    </div>

    <div id="details">
        <span>Tel: 07749 121959</span>
        <span>Email: [email protected]</span>
    </div>

    <div id="about">
        <h2>ABOUT US</h2>
        <span>Dan James construction are specialists in loft 
conversion based in North London and covering the whole of the M25 area.</span><span>We guide you through every stage of your 
development journey, right from the no obligation FREE estimate to the fine finishing touches.</span><span>So whether you're looking for more space or looking to add value get in touch today to start your very own conversion</span>
    </div>

</div>

应该可以让我知道它是如何进行的;-)

All you need to do is put another div around the left hand content and float it left, like so

<div style="float:left">
    <div id="thanks">
        <span>Thank you for your interest in Dan James construction. Please contact us using a method convenient for you.</span>
    </div>

    <div id="details">
        <span>Tel: 07749 121959</span>
        <span>Email: [email protected]</span>
    </div>

    <div id="about">
        <h2>ABOUT US</h2>
        <span>Dan James construction are specialists in loft 
conversion based in North London and covering the whole of the M25 area.</span><span>We guide you through every stage of your 
development journey, right from the no obligation FREE estimate to the fine finishing touches.</span><span>So whether you're looking for more space or looking to add value get in touch today to start your very own conversion</span>
    </div>

</div>

That should work let me know how it goes ;-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文