How to fade/blend between 2 divs in a less 'clunky' way

前端 未结 1 1901
梦如初夏
梦如初夏 2021-01-22 03:22

NB

My Header:

1条回答
  •  走了就别回头了
    2021-01-22 03:43

    'Pleasing' is a very subjective term, however to improve it you could place both div elements within a parent container positioned absolutely so they overlap. You can then fadeToggle() between the two as needed. Something like this:

    $('#container').click(function() {
      $(this).find('div').fadeToggle();
    })
    #container > div {
      position: absolute;
    }
    #divSecond {
      display: none;
    }
    
    
    some content with images
    different content with images

    Click the text to see the fade transition in action.

    0 讨论(0)
提交回复
热议问题