How to make an empty div take space

前端 未结 12 1670
广开言路
广开言路 2020-12-12 13:03

This is my 960 grid system case:

ID
相关标签:
12条回答
  • 2020-12-12 13:18

      works but that is not right way I think the w min-height: 1px;

    0 讨论(0)
  • 2020-12-12 13:19

    In building a custom set of layout tags, I found another answer to this problem. Provided here is the custom set of tags and their CSS classes.

    HTML

    <layout-table>
       <layout-header> 
           <layout-column> 1 a</layout-column>
           <layout-column>  </layout-column>
           <layout-column> 3 </layout-column>
           <layout-column> 4 </layout-column>
       </layout-header>
    
       <layout-row> 
           <layout-column> a </layout-column>
           <layout-column> a 1</layout-column>
           <layout-column> a </layout-column>
           <layout-column> a </layout-column>
       </layout-row>
    
       <layout-footer> 
           <layout-column> 1 </layout-column>
           <layout-column>  </layout-column>
           <layout-column> 3 b</layout-column>
           <layout-column> 4 </layout-column>
       </layout-footer>
    </layout-table>
    

    CSS

    layout-table
    {
        display : table;
        clear : both;
        table-layout : fixed;
        width : 100%;
    }
    
    layout-table:unresolved
    {
        color : red;
        border: 1px blue solid;
        empty-cells : show;
    }
    
    layout-header, layout-footer, layout-row 
    {
        display : table-row;
        clear : both;   
        empty-cells : show;
        width : 100%;
    }
    
    layout-column 
    { 
        display : table-column;
        float : left;
        width : 25%;
        min-width : 25%;
        empty-cells : show;
        box-sizing: border-box;
        /* border: 1px solid white; */
        padding : 1px 1px 1px 1px;
    }
    
    layout-row:nth-child(even)
    { 
        background-color : lightblue;
    }
    
    layout-row:hover 
    { background-color: #f5f5f5 }
    

    The key here is the Box-Sizing and Padding.

    0 讨论(0)
  • 2020-12-12 13:24

    This is one way:

    .your-selector:empty::after {
        content: ".";
        visibility: hidden;
    }
    
    0 讨论(0)
  • 2020-12-12 13:25

    Why not just add "min-width" to your css-class?

    0 讨论(0)
  • 2020-12-12 13:28

    Simply add a zero width space character inside a pseudo element

    .class:after {
        content: '\200b';
    }
    
    0 讨论(0)
  • 2020-12-12 13:30

    You can:

    o Set .kundregister_grid_1 to:

    • width(or width-min) with height (or min-height)
    • or padding-top
    • or padding-bottom
    • or border-top
    • or border-bottom

    o Or use pseudo-elements: ::before or ::after with:

    • {content: "\200B";}
    • or {content: "."; visibility: hidden;}.

    o Or put &nbsp; inside empty element, but this sometimes can bring unexpected effects eg. in combination with text-decoration: underline;

    0 讨论(0)
提交回复
热议问题