Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to make tabs fade in

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #278516
    lucibat
    Participant

    Im completely ignorant of js, and i have tried to look at many pens in order to incorporate it to my tabs, but nothing Ive done works. Where do I even insert the code?

    https://codepen.io/kitglitch/pen/WYQMBm

    The lil section on the bottom left are the buttons i use to change tabs btw

    #278517
    lucibat
    Participant

    Also just to clarify, i DID try to follow it up with the specific parts of the code im talking about but the generous site wont let me post when i do that.

    #278522
    Beverleyh
    Participant

    You’ll probably want to streamline the demo some more before folks will take a real look. We just need a very minimal example of the problem – no visual fluff or big chunks of content like what’s provided – we only need just enough HTML, CSS and JS to illustrate the issue.

    However, taking a cursory look at the JS, it appears that the tabs are being switched using display. Unfortunately you can’t animate the display property. With it, an element is either “there” or it’s not. Try looking to different CSS properties to animate between, such as opacity instead.

    #278531
    lucibat
    Participant

    Alright I tried to simplify it down:
    https://codepen.io/kitglitch/pen/mQVExz

    I also tried to replace

    $('#base .pages').css({
          'display' : 'none'
        });
    

    with

    $('#base .pages').css({
          'opacity' : '0'
        });
    

    But it didn’t work. Instead it rendered it ineffective.

    #278532
    Beverleyh
    Participant

    It does work, but you have to switch out all the relevant CSS and JS that uses the display property. And the show() method in jQuery uses display too https://codepen.io/anon/pen/eQJBjw

    #278618
    lucibat
    Participant

    In your pen, the divs appear to be lined up beneath one another. So I tried to give .pages an absolute display, only when I do this i cannot highlight the text, or scroll it (I applied your code to my initial pen, and found that i couldnt scroll) because the last div is placed on top of it, tho its invisible. I tried to alter the z-index of the individual tabs, tho it didn’t really make a difference and would prefer not to customize every individual tab if possible

    #278619
    Beverleyh
    Participant

    You can use the JS to change the z-index at the same time where the opacity is changed. JQuery’s css() method accepts multiple CSS definitions.

    #278620
    lucibat
    Participant

    I actually tried that at the time with 'z-index' : '9999999' and 'position' : 'fixed', both separately and together. It didn’t make a difference so I didn’t bother mentioning it.

    #278621
    Beverleyh
    Participant

    I’m on iPhone but it seems to be working for me here. The panels fade in and out and I can scroll each one, with z-index switching between 0 and 1 (no other modifications).

    #278658
    lucibat
    Participant

    Alright, so I tried fiddling around with it some more, and it worked. Thankyou for the help

    #278677
    lucibat
    Participant

    Hey again. I decided to have them slide in too, so I used a completely different code, and I don’t know how to implement fade. Could you pls help me out? I used this pen.

    https://codepen.io/bgaynor78/pen/ntGKm

    #278681
    Beverleyh
    Participant

    Why don’t you continue with your original code and look into transforming/animating the translate() property alongside opacity?

    You should also research more about transitions, and keyframe animations, to understand more about what you’re doing, and how to use them effectively.

    #278694
    lucibat
    Participant

    I have but I couldn’t get it to work. Heck, I even tried other code but given the specific properties of the divs that i want to use this for, it wouldnt work. My divs would become invisible. It just so happened to only work with this code.

    #278697
    Beverleyh
    Participant

    I have but I couldn’t get it to work.

    Ok – post your slide code modifications and we can offer suggestions as to where you went wrong. I see no reason why it wouldn’t work using translate()

    #279153
    lucibat
    Participant

    Alright, I’ll try. The reason why I also preferred the code more was because I really hate how when I control+a the whole page, it not only copies text on the visible tab, but the ones behind it too. The alternative code also doesnt just slide in. Whether it slides in right of left depends on what div you’re on. I have no idea how to even incorporate that into my initial code.

Viewing 15 posts - 1 through 15 (of 18 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.