HTML|CSS: Space between input buttons

前端 未结 6 1193
孤城傲影
孤城傲影 2020-12-12 19:24

I have a problem in which I have a space between these two buttons.

The code is as follows:



        
6条回答
  •  攒了一身酷
    2020-12-12 19:57

    As others have pointed out you can use floats to counter act the whitespace between elements

    
    
    
    .floated {
       float:left;
    }
    

    .floated {
      float:left;
    }
    
    

    As well as the various hacks for inline-block:

    1. Using 0px font-size in parent and resetting the font-size in the child elements.
        
    Some Text
    Some More Text
        .parent {
           font-size:0px;
         }
    
         .parent > * {
           display:inline-block;
           font-size:14px;
         }
    
    1. Putting all the elements next to each other, ie:
    2. Putting the closing tag on the next line and next to the next element, ie:

    3. Putting the closing bracket of the previous element on the next line and next to the next element, ie:

    4. Or using html comments

    And as stated by others this isn't an optimal solution.

    With modern browsers Flexbox styles can now be used

    .flex {
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
    }
    
    .flex-child {
        -webkit-box-flex: 0 1 auto;
        -moz-box-flex:  0 1 auto;
        -webkit-flex:  0 1 auto;
        -ms-flex:  0 1 auto;
        flex:  0 1 auto;
    }
    

    .flex {
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
    }
    
    .flex-child {
        -webkit-box-flex: 0 1 auto;
        -moz-box-flex:  0 1 auto;
        -webkit-flex:  0 1 auto;
        -ms-flex:  0 1 auto;
        flex:  0 1 auto;
    }

    A guide for flex can be found here, and support list here

提交回复
热议问题