草庐IT

html - 包含 div 的 CSS 内容溢出

coder 2023-08-05 原文

目前有一些 DIV 与其包含的 DIV 重叠的问题。见下图(底部的 3 种产品):

页面的所有正文内容都包含在#content DIV 中:

div#content {
    width: 960px;
    float: left;
    background-image: url("../img/contentBg.png");
    background-repeat: repeat;
    margin-top: 10px;
    line-height: 1.8em;
    border-top: 8px solid #5E88A2;
    padding: 10px 15px 10px 15px;
}

这是 #content div 中产品框的 CSS:

.upper {
    text-transform: uppercase;
}
.center {
    text-align: center;
}
div#products {
    float: left;
    width: 100%;
    margin-bottom: 25px;
}
div.productContainer {
    float: left;
    width: 265px;
    font-size: 1em;
    margin-left: 50px;
    height: 200px;
    padding-top: 25px;
    text-align: right;
}

div.product {
    float: left;
    width: 200px;
}
div.product p {
}
div.product a {
    display: block;
}
div.product img {
    float: left;
}
div.product img:hover {
    opacity: 0.8;
    filter: alpha(opacity = 80);
}
div.transparent {
    opacity: 0.8;
    filter: alpha(opacity = 80);
}

这是盒子的 HTML:

        <div class="productContainer">
            <div class="product">
                <h2 class="upper center">A2 Print</h2>

                <a href='../edit/?productId=5&amp;align=v' class='upper'>                   <img src="../../wflow/tmp/133703b808c91b8ec7e7c7cdf19320b7A2-Print.png" alt="Representation of image printed at A2 Print through Website." /></a>
                <p class="upper">16.5 inches x 23.4 inches<br /><strong>&pound;15.99</strong></p>
                <p class="upper smaller"><em><span><span class="yes">Yes</span> - your picture quality is high enough for this size</span>                  </em></p>

                <p><a href='../edit/?productId=5&amp;align=v' class='upper'><span>Select</span></a></p>                 
            </div>

        </div>

        <div class="productContainer">
            <div class="product transparent">
                <h2 class="upper center">A1 Print</h2>
                <a href='../edit/?productId=11&amp;align=v' class='upper'>                  <img src="../../wflow/tmp/133703b808c91b8ec7e7c7cdf19320b7A1-Print.png" alt="Representation of image printed at A1 Print through Website." /></a>
                <p class="upper">23.4 inches x 33.1 inches<br /><strong>&pound;19.99</strong></p>
                <p class="upper smaller"><em><span><span class="no">Warning</span> - your picture quality may not be sufficient for this size</span>                    </em></p>


                <p><a href='../edit/?productId=11&amp;align=v' class='upper'><span>Select</span></a></p>                    
            </div>
        </div>

        <div class="productContainer">
            <div class="product transparent">
                <h2 class="upper center">Poster Print (60cm x 80cm)</h2>
                <a href='../edit/?productId=12&amp;align=v' class='upper'>                  <img src="../../wflow/tmp/133703b808c91b8ec7e7c7cdf19320b7Poster-Print-(60cm-x-80cm).png" alt="Representation of image printed at Poster Print (60cm x 80cm) through Website." /></a>
                <p class="upper">23.6 inches x 31.5 inches<br /><strong>&pound;13.95</strong></p>

                <p class="upper smaller"><em><span><span class="no">Warning</span> - your picture quality may not be sufficient for this size</span>                    </em></p>

                <p><a href='../edit/?productId=12&amp;align=v' class='upper'><span>Select</span></a></p>                    
            </div>
        </div>

知道是什么导致这些 DIV 重叠吗?我想要的是所有框都按预期放入#container div。这让我发疯!

干杯

最佳答案

你试过设置到页脚吗

clear:both;

此外,设置为#content

overflow:hidden;

关于html - 包含 div 的 CSS 内容溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4715577/

有关html - 包含 div 的 CSS 内容溢出的更多相关文章

  1. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  2. ruby - 将数组的内容转换为 int - 2

    我需要读入一个包含数字列表的文件。此代码读取文件并将其放入二维数组中。现在我需要获取数组中所有数字的平均值,但我需要将数组的内容更改为int。有什么想法可以将to_i方法放在哪里吗?ClassTerraindefinitializefile_name@input=IO.readlines(file_name)#readinfile@size=@input[0].to_i@land=[@size]x=1whilex 最佳答案 只需将数组映射为整数:@land边注如果你想得到一条线的平均值,你可以这样做:values=@input[x]

  3. ruby - capybara field.has_css?匹配器 - 2

    我在MiniTest::Spec和Capybara中使用以下规范:find_field('Email').must_have_css('[autofocus]')检查名为“电子邮件”的字段是否具有autofocus属性。doc说如下:has_css?(path,options={})ChecksifagivenCSSselectorisonthepageorcurrentnode.据我了解,字段“Email”是一个节点,因此调用must_have_css绝对有效!我做错了什么? 最佳答案 通过JonasNicklas得到了答案:No

  4. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  5. ruby-on-rails - Rails HTML 请求渲染 JSON - 2

    在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这

  6. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  7. ruby-on-rails - 如何在我的 Rails 应用程序 View 中打印 ruby​​ 变量的内容? - 2

    我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby​​中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R

  8. ruby - 检查字符串是否包含散列中的任何键并返回它包含的键的值 - 2

    我有一个包含多个键的散列和一个字符串,该字符串不包含散列中的任何键或包含一个键。h={"k1"=>"v1","k2"=>"v2","k3"=>"v3"}s="thisisanexamplestringthatmightoccurwithakeysomewhereinthestringk1(withspecialcharacterslike(^&*$#@!^&&*))"检查s是否包含h中的任何键的最佳方法是什么,如果包含,则返回它包含的键的值?例如,对于上面的h和s的例子,输出应该是v1。编辑:只有字符串是用户定义的。哈希将始终相同。 最佳答案

  9. ruby-on-rails - Nokogiri:使用 XPath 搜索 <div> - 2

    我使用Nokogiri(Rubygem)css搜索寻找某些在我的html里面。看起来Nokogiri的css搜索不喜欢正则表达式。我想切换到Nokogiri的xpath搜索,因为这似乎支持搜索字符串中的正则表达式。如何在xpath搜索中实现下面提到的(伪)css搜索?require'rubygems'require'nokogiri'value=Nokogiri::HTML.parse(ABBlaCD3"HTML_END#my_blockisgivenmy_bl="1"#my_eqcorrespondstothisregexmy_eq="\/[0-9]+\/"#FIXMEThefoll

  10. ruby-on-rails - Ruby url 到 html 链接转换 - 2

    我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.

随机推荐