HTML, JS, CSS
Square4cards
Minimal design
Egyedi CSS design
Forráskódok
Javascript
[cc lang="javascript" tab_size=2 lines=80]
(function($) {
// ---------- INIT PAGE -------------
var sb_slide_time = 500;
initSquare4cards();
function initSquare4cards() {
$('.square4cards').each(function(i) {
$(this).attr( "id", "square4card_"+i );
$(this).height( $(this).width() );
});
$('.square4cards').find('.s4card').css( {"width": "50%"} );
$('.s4row').css( "transition-duration", sb_slide_time+"ms" );
$('.s4card').css( "transition-duration", sb_slide_time+"ms" );
$('.s4c_title').css( "transition-duration", sb_slide_time+"ms" );
$('.s4row > div').append( '
' );
$('.s4row > div').append( '
' );
$(".s4row > div .closer").hide();
$('.s4row > div .s4c_body').hide();
}
$(".square4cards .opener").on( "click", function () {
$(this).closest('.square4cards').find('.s4c_body').hide();
$(this).closest('.square4cards').find('.s4c_lead').hide( sb_slide_time );
$(this).closest('.square4cards').find('.closer').hide();
$(this).closest('.square4cards').find('.opener').hide();
$(this).hide();
$(this).parent().find(".closer").show();
// --- Open selected DIVs ----
var titleHeight = $(this).parent().find('.s4c_title').css( "height");
$(this).closest('.s4row').find('.s4card').css( {"width": titleHeight} );
$(this).closest('.s4row').find('.s4c_title').addClass( "s4c_title_90" );
$(this).closest('.s4row').find('.s4c_title').css( {"margin-top": "-"+titleHeight} );
$(this).closest('.square4cards').find('.s4c_title').addClass( "s4c_title_off" );
$(this).closest('.square4cards').find('.s4c_title').css( {"width": $(this).parent().css( "height")} );
$(this).closest('.square4cards').find('.s4row').css( {"height": titleHeight} );
$(this).closest('.s4row').css( {"height": "calc(100% - "+titleHeight+")"} );
$(this).parent().css( {"width": "100%"} );
$(this).parent().find('.s4c_title').removeClass( "s4c_title_90" );
$(this).parent().find('.s4c_title').removeClass( "s4c_title_off" );
$(this).parent().find('.s4c_title').css( {"margin-top": ""} );
$(this).parent().find('.s4c_title').css( {"width": ""} );
$(this).parent().find(".s4c_body").show( sb_slide_time );
});
$(".square4cards .closer").on( "click", function () {
$s4card = $(this).parent();
$s4card.find(".s4c_body").hide( sb_slide_time );
$s4card.find(".closer").hide();
$(this).closest('.square4cards').find('.opener').show();
$(this).closest('.square4cards').find('.s4c_lead').show( sb_slide_time );
$(this).closest('.square4cards').find('.s4row').css( {"height": "50%"} );
$(this).closest('.square4cards').find('.s4card').css( {"width": "50%"} );
$(this).closest('.square4cards').find('.s4c_title').removeClass( "s4c_title_90 s4c_title_off" );
$(this).closest('.square4cards').find('.s4c_title').css( {"margin-top": ""} );
$(this).closest('.square4cards').find('.s4c_title').css( {"width": ""} );
});
})(jQuery);
[/cc]
CSS
[cc lang="css" tab_size=2 lines=80]
.square4cards {
width: 600px;
display: block;
margin: auto;
position: relative;
overflow: hidden;
border: 1px solid #0c5460;
}
.s4row {
display: -webkit-box !important;
display: -ms-flexbox !important;
display: flex !important;
-webkit-box-orient: horizontal !important;
-webkit-box-direction: normal !important;
-ms-flex-direction: row !important;
flex-direction: row !important;
height: 50%;
}
.s4row {
display: block;
transition: height 1s ease-out;
}
.s4row .s4card {
display: inline-block;
position: relative;
align-self: stretch;
transition: width 1s ease-out;
border:0px solid #0c5460;
width: 50%;
}
.s4row .s4card:first-child { border-right-width: 1px; }
.s4row:first-child .s4card { border-bottom-width: 1px; }
.square4cards .opener,
.square4cards .closer {
position: absolute;
right: 0;
top: 0;
padding: 1rem 8px 0 0;
cursor: none;
}
.square4cards .opener:hover,
.square4cards .closer:hover {
cursor: pointer;
}
.square4cards .opener { color: #4b89cc; }
.square4cards .opener:hover { color: #113f76; }
.square4cards .closer { color: #de4224; }
.square4cards .closer:hover { color: #a01f06; }
.square4cards .s4c_title {
width: 100%;
padding: 1rem 0.5rem;
background: rgba(143, 200, 247, 1);
background: linear-gradient(90deg, rgba(143, 200, 247, 1) 0%, rgba(143, 200, 247, 0) 100%);
font-size: 1.2rem;
color: #064486;
transition: transform 1s ease-out, background 1s ease-out;
}
.square4cards .s4c_title_90 {
transform: rotate(90deg);
transform-origin: bottom left;
width: fit-content;
}
.square4cards .s4c_title_off {
background: rgba(55, 55, 55, 1);
background: linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0) 100%);
}
.square4cards .s4c_lead {
padding: 1rem 0.75rem;
font-size: 120%;
color: #064486;
text-transform: capitalize;
}
.square4cards .s4c_body {
padding: 1rem 0.75rem;
}
[/cc]
HTML
[cc lang="html5" tab_size=2 lines=40]
[/cc]