HTML, JS, CSS
RotateSquare
Minimal design
Bemutatkozás
Ez a bemutatkozás oldala ...
Szolgáltatásaink
Ez a szolgáltatásaink bemutatása ...
Kapcsolat
Ez a Kapcsolat oldal ...
Üzenetek
Itt olvashatóak az üzenetek ...
Egyedi CSS design
Bemutatkozás
Ez a bemutatkozás oldala ...
Szolgáltatásaink
Ez a szolgáltatásaink bemutatása ...
Kapcsolat
Ez a Kapcsolat oldal ...
Üzenetek
Itt olvashatóak az üzenetek ...
Forráskódok
Javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | (function($) { // -------------- INIT PAGE ---------------- var sb_slide_time = 1000; var rsSize = $('.rotatesquare').innerWidth(); var titleHeight = $('.rs_title').outerHeight(); var titleWidth = rsSize - titleHeight; var centerSize = rsSize - titleHeight - titleHeight; initRotateSquare(); function initRotateSquare() { $('.rotatesquare').each(function(i) { $(this).height( $(this).width() ); var pos = 0; $(this).children().each(function(j) { if ( $(this).is(".rscenter") ) { $(this).css({ "width": centerSize, "height": centerSize, "top": titleHeight, "left": titleHeight }); $(this).attr( "z-index", 1000); } else if ( $(this).is(".rotatesquare_content") ) { $(this).attr( "z-index", 1010); } else { pos++; $(this).attr( "rspos", pos); $(this).attr( "z-index", 1000+pos); $(this).css( "width", titleWidth); setCardPosition( this, pos ); } }); $(this).append("<div class='rotatesquare_content'></div>"); $(this).find('.rotatesquare_content').css({ "width": rsSize, "height": rsSize - titleHeight, "left": rsSize, "top": titleHeight }); $(this).find('.rotatesquare_content').hide(); $(this).css( "transition-duration", sb_slide_time+"ms" ); $(this).find('.rscenter').css( "transition-duration", sb_slide_time+"ms" ); $(this).find('.rscard').css( "transition-duration", sb_slide_time+"ms" ); $(this).find('.rs_title').css( "transition-duration", sb_slide_time+"ms" ); $(this).find('.rscard').append( '<div class="opener"><i class="fas fa-lg fa-ellipsis-v"></i></div>' ); $(this).find('.rscard').append( '<div class="closer"><i class="fas fa-lg fa-times-circle"></i></div>' ); $(this).find(".rscard .closer").hide(); $(this).find('.rscard .rs_body').hide(); $(this).parent().append('<div class="rotatesquare_area"></div>'); $(this).appendTo( $(this).parent().find('.rotatesquare_area') ); }); } function setCardPosition( obj, pos ) { if (typeof obj === 'object' && obj !== null) { switch(pos) { case 1: $(obj).css( "margin-left", titleHeight); $(obj).css( "margin-top", "0px"); break; case 2: $(obj).css( "margin-left", titleWidth); $(obj).css( "margin-top", "0px"); break; case 3: $(obj).css( "margin-left", titleWidth); $(obj).css( "margin-top", titleWidth-titleHeight-1); break; case 4: $(obj).css( "margin-left", titleHeight); $(obj).css( "margin-top", titleWidth-titleHeight-1); break; default: break; } } } $(".rotatesquare .opener").on( "click", function () { var $thisObj = $(this); $(this).closest('.rotatesquare').find('.rs_body').hide(); $(this).closest('.rotatesquare').find('.closer').hide(); $(this).closest('.rotatesquare').find('.opener').hide(); $(this).closest('.rotatesquare').find('.rs_title').addClass( "rs_title_off" ); $(this).closest('.rscard').find('.rs_title').removeClass( "rs_title_off" ); $('.rotatesquare').css( "transition-duration", sb_slide_time+"ms" ); $('.rscenter').css( "transition-duration", sb_slide_time+"ms" ); $(this).hide(); // --- Open selected DIVs ---- var pos = $(this).closest(".rscard").attr("rspos"); pos = parseInt( pos ); var openDelay = sb_slide_time; switch(pos) { case 1: openDelay = 100; break; case 2: $(this).closest('.rotatesquare').css( "transform", "rotate(-90deg)"); $(this).closest('.rotatesquare').find('.rscenter').css( "transform", "rotate(90deg)"); break; case 3: $(this).closest('.rotatesquare').css( "transform", "rotate(180deg)"); $(this).closest('.rotatesquare').find('.rscenter').css( "transform", "rotate(-180deg)"); break; case 4: $(this).closest('.rotatesquare').css( "transform", "rotate(90deg)"); $(this).closest('.rotatesquare').find('.rscenter').css( "transform", "rotate(-90deg)"); break; default: break; } $thisObj.closest('.rotatesquare_area').find('.rotatesquare_content').html( $thisObj.closest('.rscard').find('.rs_body').html() ); setTimeout( function( obj ){ for (i=1; i <= 4; i++) { var n = Math.abs( ( ( ( 4 + i - pos) % 4) ) + 1) + 10; obj.closest('.rotatesquare').find('.rscard[rspos='+i+']').attr("rspos", n); } for (i=1; i <= 4; i++) { var n = 10 + i; obj.closest('.rotatesquare').find('.rscard[rspos='+n+']').attr("rspos", i); $rscard = obj.closest('.rotatesquare').find('.rscard[rspos='+i+']'); setCardPosition( $rscard, i ); } $('.rotatesquare').css( "transition-duration", "0ms" ); $('.rscenter').css( "transition-duration", "0ms" ); obj.closest('.rotatesquare').css( "transform", "rotate(0deg)"); obj.closest('.rotatesquare').find('.rscenter').css( "transform", "rotate(0deg)"); setTimeout( function ( obj ) { $('.rotatesquare').css( "transition-duration", sb_slide_time + "ms" ); obj.closest('.rotatesquare').css( "width", 2*rsSize ); obj.closest('.rotatesquare').find('.rscard[rspos=1]').css( "width", titleWidth + rsSize ); obj.closest('.rotatesquare_area').find('.rotatesquare_content').show( sb_slide_time ); setTimeout( function ( obj ) { obj.closest('.rscard').find('.rs_title').addClass( "rs_title_on" ); obj.closest('.rscard').find(".closer").show(200); }, sb_slide_time, obj); }, sb_slide_time / 4, obj); }, openDelay, $thisObj); }); $(".rotatesquare .closer").on( "click", function () { $rscard = $(this).closest( ".rscard" ); $rscard.find(".rs_body").hide( sb_slide_time ); $rscard.find(".opener").show(); $rscard.find(".closer").hide(); $rscard.css( "width", titleWidth ); $(this).closest('.rotatesquare_area').find('.rotatesquare_content').hide( sb_slide_time / 2 ); $(this).closest('.rotatesquare').find('.rs_title').removeClass( "rs_title_off" ); $(this).closest('.rotatesquare').find('.rs_title').removeClass( "rs_title_on" ); $(this).closest('.rotatesquare').find('.opener').show(); $(this).closest('.rotatesquare').css({ "transition-duration": sb_slide_time +"ms" , "width": rsSize, "height": rsSize }); }); })(jQuery); |
CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | .rotatesquare_area { position: relative; display: block; margin: auto; width: 300px; height: 300px; } .rotatesquare { width:300px; display: block; margin: auto; position: relative; overflow: hidden; border: 1px solid #0c5460; border-radius: 6px; transition: transform 1s ease-out, background 1s ease-out, width 1s ease-out; } .rscenter { background: url("images/sx1-icon.jpg") center center no-repeat #ffffff; position: absolute; transition: transform 1s ease-out; } .rotatesquare .rscard { display: inline-block; position: absolute; align-self: stretch; transition: width 1s ease-out; border:0px solid #9a9a9a; border-bottom-width: 1px; transform-origin: bottom left; } .rscard[rspos="1"] { transform: rotate(0deg); } .rscard[rspos="2"] { transform: rotate(90deg); } .rscard[rspos="3"] { transform: rotate(180deg);; } .rscard[rspos="4"] { transform: rotate(270deg); } .rotatesquare .opener, .rotatesquare .closer { position: absolute; right: 0; top: 0; padding: 1rem 1rem 0 0; cursor: none; width: inherit; text-align: right; } .rotatesquare .opener:hover, .rotatesquare .closer:hover { cursor: pointer; } .rotatesquare .opener { color: rgba(0, 0, 0, 0.36); } .rotatesquare .opener:hover { color: rgba(0, 0, 0, 0.51); } .rotatesquare .closer { color: #bb5942; } .rotatesquare .closer:hover { color: #9b3b1b; } .rotatesquare .rs_title { width: 100%; padding: 1rem 0.5rem; background: rgba(244, 244, 244, 1); color: #333333; font-size: 1.2rem; transition: transform 1s ease-out, background 1s ease-out, width 1s ease-out; } .rotatesquare .rs_title_on { background: rgb(210, 210, 210); transition: background 1s ease-out; font-weight: bold; } .rotatesquare .rs_title_off { background: rgb(255, 255, 255); transition: background 1s ease-out; } .rotatesquare .rs_body, .rotatesquare_content { position: absolute; background: rgb(241, 241, 241); padding: 1rem; border: 1px solid #0c5460; transition: display 1s ease-out; } |
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <div class='rotatesquare'> <div class="rscenter"></div> <div class="rscard"> <div class="rs_title">Bemutatkozás</div> <div class="rs_body">Ez a bemutatkozás oldala ... </div> </div> <div class="rscard"> <div class="rs_title">Szolgáltatásaink</div> <div class="rs_body">Ez a szolgáltatásaink bemutatása ... </div> </div> <div class="rscard"> <div class="rs_title">Kapcsolat </div> <div class="rs_body">Ez a Kapcsolat oldal ... </div> </div> <div class="rscard"> <div class="rs_title">Üzenetek </div> <div class="rs_body">Itt olvashatóak az üzenetek ... </div> </div> </div> |