Left, center, and right align divs on bottom of same line

前端 未结 6 1848

I have three divs that I would like to display on the same line. Each of the three has different widths and heights, and they are not straight text. I\'d like to left-align one

6条回答
  •  情书的邮戳
    2021-02-05 09:28

    My technique is similar to @Damien-at-SF:

    I tried to rigorously demonstrate all the requirements you asked for.

    Live Demo

    HTML:

    CSS:

    #container {
        position: relative;
        height: 400px;
        width: 80%;
        min-width: 400px;
        margin: 0 auto;
    
        background: #ccc
    }
    #left, #right, #mid {
        position: absolute;
        bottom: 0;
    }
    #left {
        left: 0;
        width: 80px;
        height: 200px;
    
        background: red
    }
    #right {
        right: 0;
        width: 120px;
        height: 170px;
    
        background: blue
    }
    
    #mid {
        left:50%;
    
        margin-left: -80px;
        width: 160px;
        height: 300px;
    
        background: #f39
    }
    

提交回复
热议问题