Force sidebar height 100% using CSS (with a sticky bottom image)?

后端 未结 15 1178
再見小時候
再見小時候 2020-12-02 05:40

I\'ve been banging my head against the wall for hours trying to figure out this issue and think it must be something small I\'m missing. I\'ve searched online, but nothing

相关标签:
15条回答
  • 2020-12-02 06:29

    Further to @montrealmike 's answer, can I just add my adaptation?

    I did this:

    .container { 
      overflow: hidden; 
      .... 
    } 
    
    #sidebar { 
      margin-bottom: -101%;
      padding-bottom: 101%; 
      .... 
    } 
    

    I did the "101%" thing to cater for the (ultra rare) possibility that somebody may be viewing the site on a huge screen with a height more than 5000px!

    Great answer though, montrealmike. It worked perfectly for me.

    0 讨论(0)
  • 2020-12-02 06:29

    i guess, today one would probably use flexbox for this. See the holy grail example.

    0 讨论(0)
  • 2020-12-02 06:31

    use body background if you are using fixed width sidebar give the same width image as your side bar. also put background-repeat:repeat-y in your css codes.

    0 讨论(0)
  • 2020-12-02 06:33

    I think your solution would be to wrap your content container and your sidebar in a parent containing div. Float your sidebar to the left and give it the background image. Create a wide margin at least the width of your sidebar for your content container. Add clearing a float hack to make it all work.

    0 讨论(0)
  • 2020-12-02 06:34

    Flexbox (http://caniuse.com/#feat=flexbox)

    First wrap the columns you want in a div or section, ex:

    <div class="content">
        <div class="main"></div>
        <div class="sidebar"></div>
    </div>
    

    Then add the following CSS:

    .content {
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
    }
    
    0 讨论(0)
  • 2020-12-02 06:38

    This worked for me

    .container { 
      overflow: hidden; 
      .... 
    } 
    
    #sidebar { 
      margin-bottom: -5000px; /* any large number will do */
      padding-bottom: 5000px; 
      .... 
    } 
    
    0 讨论(0)
提交回复
热议问题