Align Div at bottom on main Div

后端 未结 5 1576
北荒
北荒 2020-12-28 14:16

I have two divs, one inside the other and I would like the small div to be aligned at the buttom of the main div.

Here\'s my code so far. Currently, the button is at

相关标签:
5条回答
  • 2020-12-28 14:34

    This isn't really possible in HTML unless you use absolute positioning or javascript. So one solution would be to give this CSS to #bottom_link:

    #bottom_link {
        position:absolute;
        bottom:0;
    }
    

    Otherwise you'd have to use some javascript. Here's a jQuery block that should do the trick, depending on the simplicity of the page.

    $('#bottom_link').css({
        position: 'relative',
        top: $(this).parent().height() - $(this).height()
    });
    
    0 讨论(0)
  • 2020-12-28 14:40

    Modify your CSS like this:

    .vertical_banner {
        border: 1px solid #E9E3DD;
        float: left;
        height: 210px;
        margin: 2px;
        padding: 4px 2px 10px 10px;
        text-align: left;
        width: 117px;
        position:relative;
    }
    
    #bottom_link{
       position:absolute;                  /* added */
       bottom:0;                           /* added */
       left:0;                           /* added */
    }
    <div class="vertical_banner">
        <div id="bottom_link">
             <input type="submit" value="Continue">
           </div>
    </div>

    0 讨论(0)
  • 2020-12-28 14:41

    Give your parent div position: relative, then give your child div position: absolute, this will absolute position the div inside of its parent, then you can give the child bottom: 0px;

    See example here:

    http://jsfiddle.net/PGMqs/1/

    0 讨论(0)
  • 2020-12-28 14:51

    I guess you'll need absolute position

    .vertical_banner {position:relative;}
    #bottom_link{position:absolute; bottom:0;}
    
    0 讨论(0)
  • 2020-12-28 14:53

    Please try this:

    #b {
    display: -webkit-inline-flex;
    display: -moz-inline-flex;
    display: inline-flex;
    
    -webkit-flex-flow: row nowrap;
    -moz-flex-flow: row nowrap;
    flex-flow: row nowrap;
    
    -webkit-align-items: flex-end;
    -moz-align-items: flex-end;
    align-items: flex-end;}
    

    Here's a JSFiddle demo: http://jsfiddle.net/rudiedirkx/7FGKN/.

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