Have block level element fill 100% width of overflow-x: scroll container

后端 未结 4 1945
时光取名叫无心
时光取名叫无心 2021-01-18 05:58

I\'ve got a container element that\'s a certain width, with overflow-x: auto. In it I have a block level header element (h1) that\'s supposed to, being a block

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-18 06:51

    Try this:

    css

    #one {
        width: 200px;
        overflow: auto;
        border: solid 1px;
    }
    
    #one h1 {
        font-size 1.1em;
        background-color: blue;
        display: inline-block;
        width: 100%;
        margin-top: 0;
        position:relative;
    }
    
    table td {
        border: solid 1px;
        padding: 20px;
    }
    
    h1:after {
         content:"";
         background: blue;
         position: absolute;
         top: 0;
         bottom: 0;
         width: 100%;
        left:100%
     }
    

    fiddle

提交回复
热议问题