简体   繁体   English

不同列之间的边界距离

[英]Border distance between different columns

This is what i´m trying to achieve: 这是我想要实现的目标: 在此处输入图片说明

The problem I have is that on resize the blank space between the columns always change looking different on width and height from the others: 我的问题是,在调整大小时,列之间的空白总是在宽度和高度上看起来与其他列不同:

This is my markup: 这是我的标记:

<div id="wrapper">  
   <div id="header" class="clearfix"></div>
   <div class="layout clearfix"> 
   <div class="small_box top_left ">
    <img class="fittobox" src="img/home7.jpg" alt="home7" width="800" height="689">
   </div>
   <div class="small_box top_middle large_h">
    <img class="fittobox" src="img/home6.jpg" alt="home6" width="747" height="1330">
   </div>
   <div class="small_box top_right">
    <img class="fittobox" src="img/home5.jpg" alt="home5" width="503" height="460">
   </div>
   <div class="small_box bottom_left">
     <img class="fittobox" src="img/home2.jpg" alt="home2" width="830" height="800">
   </div>
   <div class="small_box bottom_right">
     <img class="fittobox" src="img/home7.jpg" alt="home7" width="800" height="689">
   </div>               
   </div><!-- Layout -->        
 </div><!-- wrapper -->

With this LESS: 使用此LESS:

    /*---- HOME - SHOP - TIENDAS LAYOUT ----*/
    .layout{
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        right: 0px;
        bottom: 0px;
        z-index: 1;
        overflow: hidden;
        min-height: 100%;
        max-height: 100%;
        .fittobox{
            display: none;
        }
        .small_box{
            width: 33%;
            overflow: hidden;
            height: 45%;
            position: absolute;
            &.top_left{
                top: 3%;
            }
            &.top_middle{
                top: 3%;
                left: 50%;
                margin-left: -16%;
            }
            &.top_right{
                top: 3%;
                right: 0;
                margin-right: 0;
                width: 32%;
            }
            &.bottom_left{
                bottom: 40px;
                left: 0;
            }
            &.bottom_middle{
                bottom: 40px;
                left: 50%;
                margin-left: -16%;
            }
            &.bottom_right{
                bottom: 40px;
                right: 0;
                margin-right: 0;
                width: 32%;
            }
            &.large_h{
                top: 3%;
                height: 93%;
            }
            &.fullscreen{
                width: 100%;
                height: 100%;
            }
            &.halfscreen{
                width: 67%;
                height: 93%;
                top: 3%;
            }
    }

The standard box model places stuff like the borders, paddings and margins outside of the box. 标准盒子模型将诸如边框,边距和边距之类的东西放置在盒子外面。

This means that if you have a group of boxes with sizes in percentages that you want to add up to 100%, you can't have padding between them. 这意味着,如果您有一组框,它们的大小百分比要加到100%,则它们之间不能有填充。

However you can change the box model so that the padding etc is inside the box, using CSS box-sizing:border-box; 但是,您可以使用CSS box-sizing:border-box;更改盒子模型,使填充等位于box-sizing:border-box; .

With this set, you can now specify your boxes so that they add up to 100%, but still give them padding and margin in pixels without messing up the layout. 使用此设置,您现在可以指定框,使其总计达到100%,但仍以像素为单位提供填充和边距,而不会弄乱布局。

Hope that helps. 希望能有所帮助。

Read more about box-sizing here: https://developer.mozilla.org/en-US/docs/CSS/box-sizing 在此处阅读有关box-sizing更多信息: https : //developer.mozilla.org/en-US/docs/CSS/box-sizing

Browser compatibility: Not supported in IE6 or IE7. 浏览器兼容性:IE6或IE7不支持。 Works fine in all other browsers. 在所有其他浏览器上都可以正常工作。 (polyfills for IE6/7 can be found here ). 可在此处找到 IE6 / 7的polyfill)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM