CSS Layout - Dynamic width DIV

前端 未结 4 975
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 03:43

I have a pretty common layout issue that I have traditionally used a table to solve, but would like some advice on getting it done with CSS. I have 3 images that makeup a \'

4条回答
  •  有刺的猬
    2020-12-31 04:15

    Or, if you know the width of the two "side" images and don't want to deal with floats:

    Content goes here...

    CSS:

    .container {
        position:relative;
        padding-left:50px;
        padding-right:50px;
    }
    
    .container .left-panel {
        width: 50px;
        position:absolute;
        left:0px;
        top:0px;
    }
    
    .container .right-panel {
        width: 50px;
        position:absolute;
        right:0px;
        top:0px;
    }
    
    .container .center-panel {
        background: url('mymiddleimage');
    }
    

    Notes:

    Position:relative on the parent div is used to make absolutely positioned children position themselves relative to that node.

提交回复
热议问题