How do I stretch two div-elements to fill available horizontal space?

前端 未结 3 1629
[愿得一人]
[愿得一人] 2021-01-18 04:11

I really hope that you can help me.

I created this fiddle to show what I\'m trying to do.

My question is: How do I stretch two div-elements to fill available

3条回答
  •  天涯浪人
    2021-01-18 04:59

    You can do it with help of javascript. Change div tags like this:

    section2

    section4

    And add this javascript somehwere after those tags:

    
        var elem1 = document.getElementById("part1");
        elem1.style.width = (screen.width - 150)/2;
        var elem2 = document.getElementById("part2");
        elem2.style.width = (screen.width - 150)/2;
    

    And remove width:50%; from sectionFillUp in css

提交回复
热议问题