CSS:高度不规则的瓦片盒

发布于 2024-09-28 01:22:59 字数 4983 浏览 0 评论 0原文

我想将框平铺成如下图所示,

alt text

所有框都具有相同的宽度和高度,接受其中之一我需要在某些情况下将其高度更改为 500px。但我做不到!

http://rokhsanafiaz.co.uk/dump/1.php

这是我的css

* { 
    margin: 0; 
    padding: 0; 
    }

h1,h2,h3,h4,h5,h6,pre,code,address,caption,cite,code,th { 
    font-size: 1em; 
    font-weight: normal; 
    font-style: normal;
    }

ul,ol,li { 
    list-style: none; 
    margin:0px; 
    padding:0px;
    }

fieldset,img { 
    border: none;
    padding:0px;
    margin:0px;
    float:left; /** a must so that there is no extra gap at the bottom of each image **/
    }

div {
    clear:both;
    border:1px solid #0066FF;
    overflow:hidden;
    }

#main {
    width:785px;
    /**height:837px;  a must for IE, to be handled in jquery **/
    position:relative !important; /** essential for sticking #company at bottom **/
    border:1px solid #000;
    }

#main div {
    clear:none;
    }

.item-global {
    width:335px;
    height:146px;
    background:#ffffff;
    padding:15px;
    position:relative;
    float:left;
    margin: 0px 15px 15px 0px;
    }

.item-global h3 {
    border:0px solid #000;
    margin:0px 0px 5px 0px;
    }

.item-global h3  a{
    font-size:20px;
    color:#0099cc;
    }

.item-global p{
    margin:0px;
    padding:0px;
    font-size:14px;
    line-height:18px;
    clear:both;
    }

.item-global-current {
    height:400px;
    }

和我的标记,

<!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 1</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

    <!-- item-global -->
    <div class="item-global round-corner item-global-current" style="float:none; clear:none;">

        <h3><a href="#">Topic 2</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>


        <a href="#" class="button-top-minus"><span>less</span></a>
        <a href="#" class="button-bottom-minus"><span>less</span></a>

    </div>
    <!-- item-global -->


    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 3</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 4</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->


    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 5</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 6</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

如果你知道这些技巧那就太棒了!谢谢!

I want to tile boxes to look like this picture below,

alt text

which all the boxes have the same width and height, accept one of them I need to change its height to 500px for certain occasions. But I cannot make it right!

http://rokhsanafiaz.co.uk/dump/1.php

here is my css,

* { 
    margin: 0; 
    padding: 0; 
    }

h1,h2,h3,h4,h5,h6,pre,code,address,caption,cite,code,th { 
    font-size: 1em; 
    font-weight: normal; 
    font-style: normal;
    }

ul,ol,li { 
    list-style: none; 
    margin:0px; 
    padding:0px;
    }

fieldset,img { 
    border: none;
    padding:0px;
    margin:0px;
    float:left; /** a must so that there is no extra gap at the bottom of each image **/
    }

div {
    clear:both;
    border:1px solid #0066FF;
    overflow:hidden;
    }

#main {
    width:785px;
    /**height:837px;  a must for IE, to be handled in jquery **/
    position:relative !important; /** essential for sticking #company at bottom **/
    border:1px solid #000;
    }

#main div {
    clear:none;
    }

.item-global {
    width:335px;
    height:146px;
    background:#ffffff;
    padding:15px;
    position:relative;
    float:left;
    margin: 0px 15px 15px 0px;
    }

.item-global h3 {
    border:0px solid #000;
    margin:0px 0px 5px 0px;
    }

.item-global h3  a{
    font-size:20px;
    color:#0099cc;
    }

.item-global p{
    margin:0px;
    padding:0px;
    font-size:14px;
    line-height:18px;
    clear:both;
    }

.item-global-current {
    height:400px;
    }

and my markups,

<!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 1</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

    <!-- item-global -->
    <div class="item-global round-corner item-global-current" style="float:none; clear:none;">

        <h3><a href="#">Topic 2</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>


        <a href="#" class="button-top-minus"><span>less</span></a>
        <a href="#" class="button-bottom-minus"><span>less</span></a>

    </div>
    <!-- item-global -->


    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 3</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 4</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->


    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 5</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

    <!-- item-global -->
    <div class="item-global round-corner">

        <h3><a href="#">Topic 6</a></h3>

        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy Lorem Ipsum has been the industry's standard dummy</p>

        <a href="#" class="button-plus"><span>more</span></a>

    </div>
    <!-- item-global -->

it would be fantastic if you know the tricks! thanks!

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

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

发布评论

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

评论(2

溺深海 2024-10-05 01:22:59

我认为,单独声明两个列容器而不是将所有 7 个元素混合在一起会更容易。 示例
至少,这是我通常采用的原则:容器可以水平或垂直地拆分为子容器,但不能同时在两个方向上拆分。

<div class="column">
    <div class="normal">1</div>
    <div class="normal">3</div>
    <div class="normal">4</div>
</div>
<div class="column">
    <div class="large">2</div>
    <div class="normal">5</div>    
</div>

I think, it will be easier for you to declare two column containers separately and not mix all 7 elements together. An example.
At least, this is the principle I usually employ: container can be split into subcontainers horizontally or vertically, but not in both directions together.

<div class="column">
    <div class="normal">1</div>
    <div class="normal">3</div>
    <div class="normal">4</div>
</div>
<div class="column">
    <div class="large">2</div>
    <div class="normal">5</div>    
</div>
日久见人心 2024-10-05 01:22:59

添加如何:

.item-global-current + div { margin-top:-195px; }

适用于 Firefox 3.6.8。

How about adding:

.item-global-current + div { margin-top:-195px; }

Works in Firefox 3.6.8.

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