草庐IT

javascript - 在 div 的最后一行平铺 div 等高

coder 2023-08-07 原文

大家好,有没有办法实现以下设计? 我设计了我的 div,但我不知道如何得到它。div 位于页面的中心,所有这些 div 的包装宽度都可以调整。

正常内容

当 wrapper 变小时,它将是一个两列的 div,最后一个仍然相等。 * wrapper div 在放大和缩小时调整其宽度..

代码

<html>
<head>
<title></title> 

<link rel="stylesheet" href="view/css/ui-layout.css" type="text/css"/>
<link rel="stylesheet" href="view/css/layout.css" type="text/css"/>
<script type="text/javascript" src="view/js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="view/js/equalheight.js"></script>

<style>
 html,body{
   padding: 0;
   margin:0;
   min-width: 820px;
   color: #333333;
   background-color: #F1F1f1;
   font-family: Arial, Helvetica, Sans-Serif;
   font-style: normal;
   font-weight: normal;
   font-size: 13px;
}
a{
    text-decoration:none;
        color:#3EA7bb;
        cursor: pointer;
}

ul{
    display: inline-block;
     position: relative;
}

hr{
    border:1px solid #f1f1f1;
}
.cleared
{
   display:block;
   clear: both;
   float: none;
   margin: 0;
   padding: 0;
   border: none;
   font-size: 0;
   height:0;
   overflow:hidden;
}
.reset-box
{
   overflow:hidden;
   display:table;
}

#main-container{
   width: 80%;
   min-height: 100%; 
    min-width: 820px;
    max-width: 1000px;
   z-index: 0;
   left: 0;
   top: 0;
   cursor:default;
   overflow:hidden;  
   background-color:#FFFFFF; 
   position: relative;
   margin: 0 auto; 
   padding-left: 20px;
   padding-right: 20px;
   -moz-box-shadow: 0 0 0 5px #333333;
    -webkit-box-shadow: 0 0 0 5px #333333;
    box-shadow: 0 0 5px #333333; 
}

#header{

    height: 100px; 

    padding-top: 5px; 
    margin:0 auto;  
}
#header-logo{
    width: 308px;
    height: 100px;
    background-image: url(../images/skerp.png);
    background-position: center;
    background-repeat: no-repeat; 
    margin-left: 20px; 
}
#menu-bar{ 

   margin:0 auto; 
   min-height: 25px;
   z-index: 100;
   margin-top: 0;
   margin-bottom: 0; 
   border-radius:0px;
   /*-moz-box-shadow: 0 0 0 3px #333333;
   -webkit-box-shadow: 0 0 0 3px #333333;
    box-shadow: 0 0 3px #333333;*/
   -moz-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
    -webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
    box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
    margin:0 auto; 

} 
#menu-wraper{
    display: inline-block;
    float: right;
    margin-right: 10px;

}
.menu-element{ 
    min-width: 75px;
    height: 25px;
    display:inline-block;
    cursor: pointer;  
    text-align:center;
} 

#body-container{

    margin:0 auto;
    padding-bottom: 90px;  
}


.left-container,.right-container,.center-container{
    display: block;
    float:left;

} 
.featured{
margin:20px auto;
padding:5px; 
-moz-box-shadow: 0 0 0 5px #333333;
-webkit-box-shadow: 0 0 0 5px #333333;
box-shadow: 0 0 5px #333333; 
border-radius: 5px;
min-height: 300px;
width: 780px;
}

.left
{ 
    text-align: left; 
}
.left span{
    float:left;
    left:0;
}
.right
{ 
    text-align: right; 
}
.right span{
    right:0; 
    float:right;
}
.main-under-color{
    width: 300px;
    height:5px;
    display: block;
}
.sub-under-color{
    width: 100px;
    height:5px;
    display:  block; 
}
.content-wrapper{
    margin:10px auto;
    min-width: 810px; 
    /*padding:10px;*/ 
}

.content-wrapper h1{
    text-align: left;
}
.image-wrapper{
    margin: 0 auto;

}
.page-title{   
    padding: 20px 10px 10px 10px; 
    display: block; 
}
.page-title h1{
    font-weight: bold; 
    font-size: 40px;
    text-indent: 20px;
}

.content-title h1{
    font-weight: bold; 
    font-size: 20px; 
}
.content{ 
    padding:0px;/* 15px  15px 15px;*/
    display: block;
    font-size: 15px;  
}
.content p{
    text-align: justify;
    line-height: 25px;
    word-spacing: 1px;
    word-wrap:break-word; 
}
.border{  
    -moz-box-shadow: 0 0 0 5px #999999;
    -webkit-box-shadow: 0 0 0 5px #999999;
    box-shadow: 0 0 5px #999999; 
    border-radius: 5px;
    border:1px solid #999999; 
}

.border-top{
    border-top:1px solid #999999; 
}
.border-left{ 
    border-left:1px solid #999999; 
}
.border-right{  
    border-right: 1px solid #999999; 
}
.border-bottom{  
    border-bottom: 1px solid #999999; 
}


   .column-wrapper{
       padding-top: 20px;
       text-align: center;
       vertical-align:middle;
       width:100%;    

    }

    .column-wrapper div{ 
        display: inline-table;
        margin:2px;  


    }
    .column-small{
        padding:10px;
        padding-bottom:30px;
        width:30%; 
        min-width: 250px; 
        position: relative;  
    } 

     .fixedbottomReadMore{
        position: absolute;
        bottom: 10px;
        right: 20px;
    } 
     .fluedbottomReadMore{
        position: absolute;
        float:right;
        right:20px;
    } 
    .column-small ul{
        margin-top: -10px;
        width: 100%; 
        max-width: 240px;
    }
    .column-small ul li{
        text-align: left;  
    }
    .column-small li{ 
        list-style: none;
        padding: 5px;
        text-indent: -30px;
        word-wrap: break-word;
    }
    .column-medium{

    padding:10px;
        width: 61%;
        min-width: 505px;
    }
    .column-large{
    padding:10px;
        width: 100%;
        min-width: 760px; 
    }



</style>
</head>
<body>
<div id="main-container">


    <div id="body-container" > 

        <div class="content-wrapper ">  
            <div class="cleared"></div>
                <div class="content ">

                    <div class="cleared"></div>
                    <div class="column-wrapper ">
                        <div class="column-large "> 

                        </div>
                    </div>
                    <div class="cleared"></div>
                    <div class="column-wrapper"> 
                        <div class="column-small border  border-top"> 
                            <h3>Features</h3> 
                             <ul>
                                 <li>Code blocking</li>
                                 <li>Code Wrapping</li>
                                 <li>Code Killing</li>
                                 <li>Code Sleeping</li>
                             </ul>
                            <span class="fixedbottomReadMore"><a href="#">Read more</a></span>

                        </div>

                        <div class="column-small border  border-top"> 
                            <h3>Modules</h3>
                             <ul>
                                 <li>Barking Around The house</li>
                                 <li>Loving the Cats</li>
                                 <li>Floating The points</li>
                                 <li>Coding The Sleepers</li>
                                 <li>Coding The Sleepers</li>
                             </ul>
                             <span class="fixedbottomReadMore"><a href="#">Read more</a></span> 
                        </div>

                        <div class="column-small border  border-top"> 
                             <h3>Idont knows</h3>
                             <span class="fixedbottomReadMore"><a href="#">Read more</a></span>

                        </div>

                        <div class="column-small border  border-top"> 
                            <h3>Modules</h3>
                             <ul>
                                 <li>Barking Around The house</li>
                                 <li>Loving the Cats</li>
                                 <li>Floating The points</li>
                                 <li>Coding The Sleepers</li>
                                 <li>Coding The Sleepers</li>
                             </ul>
                             <span class="fixedbottomReadMore"><a href="#">Read more</a></span>

                        </div>
                        <div class="column-small border  border-top"> 
                             <h3>Idont knows</h3>
                             <span class="fixedbottomReadMore"><a href="#">Read more</a></span>

                        </div>

                    </div>
                </div> 
        </div>
        <script>
            $('.column-wrapper .column-small').equalHeightColumns();
        </script>
    </div>  
    <div class="cleared reset-box"></div>

  </div>
</body>
</html>

最佳答案

我不知道这是否适合您的情况,但是,下面的 fiddle 在 DIV 的底部。

我不确定的是,当您将其转换为两列模型时,所有 block 都将可见,如果您最终在最后一行显示两个 block ,那么底部将对齐到底部。

看看这是否有帮助 - http://jsfiddle.net/AUV7J/

span设为display: table-cell,我们可以将其中的 block 垂直对齐到底部

更新:

如您所说,您不希望中间有空格。您必须以编程方式调整每一列的最后一个 DIV 的大小

查看更新的 Fiddle

更新:

有关动态列,请参阅 this

关于javascript - 在 div 的最后一行平铺 div 等高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14906561/

有关javascript - 在 div 的最后一行平铺 div 等高的更多相关文章

  1. 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

  2. ruby - 如何使用 Selenium Webdriver 根据 div 的内容执行操作? - 2

    我有一个使用SeleniumWebdriver和Nokogiri的Ruby应用程序。我想选择一个类,然后对于那个类对应的每个div,我想根据div的内容执行一个Action。例如,我正在解析以下页面:https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=puppies这是一个搜索结果页面,我正在寻找描述中包含“Adoption”一词的第一个结果。因此机器人应该寻找带有className:"result"的div,对于每个检查它的.descriptiondiv是否包含单词“adoption

  3. ruby - Hanami link_to 助手只呈现最后一个元素 - 2

    我是HanamiWorld的新人。我已经写了这段代码:moduleWeb::Views::HomeclassIndexincludeWeb::ViewincludeHanami::Helpers::HtmlHelperdeftitlehtml.headerdoh1'Testsearchengine',id:'title'hrdiv(id:'test')dolink_to('Home',"/",class:'mnu_orizontal')link_to('About',"/",class:'mnu_orizontal')endendendendend我在模板上调用了title方法。htm

  4. ruby - 如果它是标点符号,我怎么能从字符串中删除最后一个字符,在 ruby​​ 中? - 2

    啊,正则表达式有点困惑。我正在尝试删除字符串末尾所有可能的标点符号:ifstr[str.length-1]=='?'||str[str.length-1]=='.'||str[str.length-1]=='!'orstr[str.length-1]==','||str[str.length-1]==';'str.chomp!end我相信有更好的方法来做到这一点。有什么指点吗? 最佳答案 str.sub!(/[?.!,;]?$/,'')[?.!,;]-字符类。匹配这5个字符中的任何一个(注意,。在字符类中并不特殊)?-前一个字符或组

  5. ruby-on-rails - 使用 javascript 更改数据方法不会更改 ajax 调用用户的什么方法? - 2

    我遇到了一个非常奇怪的问题,我很难解决。在我看来,我有一个与data-remote="true"和data-method="delete"的链接。当我单击该链接时,我可以看到对我的Rails服务器的DELETE请求。返回的JS代码会更改此链接的属性,其中包括href和data-method。再次单击此链接后,我的服务器收到了对新href的请求,但使用的是旧的data-method,即使我已将其从DELETE到POST(它仍然发送一个DELETE请求)。但是,如果我刷新页面,HTML与"new"HTML相同(随返回的JS发生变化),但它实际上发送了正确的请求类型。这就是这个问题令我困惑的

  6. Ruby - 删除文件中的最后一个字符? - 2

    看起来一定很简单,但我就是想不通。如何使用RubyIO删除文件的最后一个字符?我查看了deletingthelastlineofafile的答案使用Ruby但没有完全理解它,必须有更简单的方法。有什么帮助吗? 最佳答案 有File.truncate:truncate(file_name,integer)→0Truncatesthefilefile_nametobeatmostintegerbyteslong.Notavailableonallplatforms.所以你可以这样说:File.truncate(file_name,Fil

  7. ruby-on-rails - Ruby on Rails 的最后 20% - 2

    我是(相当)一位经验丰富的程序员,但对Ruby和RubyonRails完全陌生。RoR看起来很适合快速工作,特别是用于CRUD操作的自动屏幕生成。它确实能让您快速提高工作效率。问题是最后20%的工作,那时我必须完成我的申请。RoR公约不会妨碍我吗?因为不是每个数据库表都必须对所有用户可用,也不是所有用户都可以编辑所有列和/或所有行,而且View必须适应我网站的外观等。我知道RoR已成功用于现场,但在第一阶段烧毁后,如何在RoR中获得足够的速度以逃避重力。 最佳答案 我认为脚手架无法让您达到80%。脚手架很好,因为它向您展示了Rail

  8. arrays - 在一行中选择数组的第一个和最后一个元素 - 2

    我的任务是从数组中选择最高和最低的数字。我想我很清楚我想做什么,但只是努力以正确的格式访问信息以满足通过标准。defhigh_and_low(numbers)array=numbers.split("").map!{|x|x.to_i}array.sort!{|a,b|ba}putsarray[0,-1]end数字可能看起来像"80917234100",要通过,我需要输出"9234"。我正在尝试putsarray.first.last,但一直无法弄明白。 最佳答案 有Array#minmax完全满足您需要的方法:array=[80,

  9. ruby - 在 Mechanize 中使用 JavaScript 单击链接 - 2

    我有这个:AccountSummary我想单击该链接,但在使用link_to时出现错误。我试过:bot.click(page.link_with(:href=>/menu_home/))bot.click(page.link_with(:class=>'top_level_active'))bot.click(page.link_with(:href=>/AccountSummary/))我得到的错误是:NoMethodError:nil:NilClass的未定义方法“[]” 最佳答案 那是一个javascript链接。Mechan

  10. ruby - 如何使用 Ruby 从 CSV 中删除一行 - 2

    给定以下CSV文件,您将如何删除列“foo”中包含单词“true”的所有行?Date,foo,bar2014/10/31,true,derp2014/10/31,false,derp我有一个可行的解决方案,但它需要制作一个辅助CSV对象csv_no_foo@csv=CSV.read(@csvfile,headers:true)#http://bit.ly/1mSlqfA@headers=CSV.open(@csvfile,'r',:headers=>true).read.headers#MakeanewCSV@csv_no_foo=CSV.new(@headers)@csv.eachd

随机推荐