Fixed width div on left, fill remaining width div on right

前端 未结 2 1355
庸人自扰
庸人自扰 2021-02-01 01:26

I want a div with a fixed width image on the left and a variable width div with a background color, which should extend its width 100% on my device. I can\'t stop the second div

2条回答
  •  时光取名叫无心
    2021-02-01 01:43

    Try removing the float:left and width:100% from .header-right — the right div then behaves as requested.

    .header {
      float: left;
      background: #efefef;
      background-repeat: no-repeat;
      width: 240px;
      height: 100px;
    }
    
    .header-right {
      overflow: hidden; 
      background-color: #000;
      height: 100px;
    }

提交回复
热议问题