Yes, the CJ-7 hardtop will fit with your YJ. You will have to make some modifications--by the windshield and by the tailgate--if you want to make it perfectly functional. As for the YJ tailgates, I believe they are all the same. I ran a CJ hardtop on my YJ, so if you have any questions about the setup, I'd be glad to help you out.
1990 Red YJ 2.54 L (Rebuilt) 5 Speed with 94 rollbar | Dynomax Exhaust | Luk Clutch
2.5" Old Man Emu over 31x10.50 BFG MTs on 15x8 AR 767s | 1" Daystar Body Lift
Two Tops | Full and Half Doors | KC Daylighters | Hella 5500 | OME Steering Stabiliser
Sony CDX-GT300 | Kicker ZX500.1 | Kicker ZX350.4 | Kicker ZX200.2 | Kicker L5 Solobaric Sub | Kicker 6x9's | Apline 6.5's | Boston 4x6's
Truckstop CB Antenna | Class 3 Hitch