Skip to content

Instantly share code, notes, and snippets.

@VicVicos
Last active August 12, 2020 03:41
Show Gist options
  • Select an option

  • Save VicVicos/4aebb367a152e75e2553d2771038f39e to your computer and use it in GitHub Desktop.

Select an option

Save VicVicos/4aebb367a152e75e2553d2771038f39e to your computer and use it in GitHub Desktop.
Tabs (responsive)
<div data-tab-id="product-tabs" class="ms-tabs-block ms-col ms-hidden ms-d-flex ms-f-center">
<nav class="nav ms-tabs-link">
<a class="nav-link active" id="tl_buy_now" href="#buy_now">Buy Now</a>
<a class="nav-link" id="tl_subscription" href="#subscription">Subscription</a>
</nav>
</div>
<div id="product-tabs" class="ms-tabs-content ms-col">
<div id="buy_now" class="active ms-tabs__block">
<a href="#" class="ms-visible ms-spoiler-trigger"><span>Buy Now</span></a>
<div class="ms-spoiler-block">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur debitis error eum
exercitationem explicabo illo in magnam nesciunt nobis non numquam quidem ratione tenetur, velit
veritatis. A libero maiores voluptates?</p>
</div>
</div>
<div id="subscription" class="ms-tabs__block">
<a href="#" class="ms-visible ms-spoiler-trigger"><span>Subscription</span></a>
<div class="ms-spoiler-block">
<p>112Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad earum illum laboriosam nulla
officiis quis rem sunt voluptate. At eligendi facere ipsa libero maxime nobis numquam odit sunt
voluptas voluptatibus.</p>
</div>
</div>
</div>
(function ($){
function tabs() {
$('.product-info.summary').on('click', '.ms-tabs-link a', function (event) {
event.preventDefault();
var $this = $(this),
parent = $this.parents('.ms-tabs-block'),
idTab = parent.attr('data-tab-id'),
tab = $('#' + idTab),
href = $this.attr("href");
window.location.href = window.location.origin + window.location.pathname + href;
if ($(href).length) {
parent.find('.nav-link').removeClass('active');
$('#' + idTab + ' > *').removeClass('active'); // tab.find(' > .ms-tabs__block').removeClass('active');
$this.addClass('active');
$(href).addClass('active');
}
});
}
function activeTabs() {
var activeTab = $('.ms-tabs-block a[href="' + window.location.hash + '"]');
if (activeTab.length) {
activeTab.trigger('click');
}
}
function spoiler() {
$(document).on('click', '.ms-spoiler-trigger', function (e) {
e.preventDefault();
$(this).toggleClass('active');
$(this).parent().toggleClass('active-spoiler').find('.ms-spoiler-block').first().toggleClass('active');
});
}
tabs();
activeTabs();
spoiler();
})(jQuery);
.ms-tabs-link {
display: flex;
justify-content: flex-start;
flex-wrap: nowrap;
}
.ms-tabs-link a {
color: #999999;
font-size: 16px;
font-weight: 400;
line-height: 20px;
padding: 20px;
text-decoration: none;
outline: none;
}
.ms-tabs-link a.active {
color: #0e0d12;
background-color: #fff;
}
.ms-tabs-content > div {
display: none;
padding: 0;
}
.ms-tabs-content > div.active {
display: block;
background-color: #fff;
}
.ms-tabs-content p.ms-tabs-content_text {
color: #0e0d12;
font-size: 14px;
font-weight: 400;
line-height: 25px;
margin-bottom: 35px;
}
.ms-tabs-content p.title {
font-weight: 700;
font-size: 16px;
margin-bottom: 10px;
}
.ms-tabs-content .ms-tabs-block form {
max-width: 700px;
margin: 0 auto;
}
.ms-visible.spoiler-trigger + div {
display: block;
}
.ms-spoiler-trigger {
color: #999999;
font-size: 16px;
font-weight: 400;
line-height: 40px;
text-decoration: none;
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAALCAMAAABFyS02AAAAAXNSR0IB2cksfwAAADNQTFRFAAAAYGBgZWVlaGhoZWVlZWVlZmZmZmZmZWVlZ2dnZ2dnZmZmZmZmZmZmZmZmZmZmZmZmdm5wIgAAABF0Uk5TABA/IDCw/89gkJ/woO/QUK9g+KnVAAAAT0lEQVR4nFXNSRKAMAhE0cZgG00c7n9aIVYhYdX1Fh/IgnxFgZVbkkoqdvIIUbIJ0H/Tk019hIV4blgSyOVmwjuqbo9JTb/dZvlsFrMenRftQgJMTlIEIQAAAABJRU5ErkJggg==") no-repeat 100% 50%;
}
.ms-spoiler-trigger.active {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAYAAABSfLWiAAAAkElEQVQoU43SwQ2DMAwF0PwswCrtBozACPTgLOUDHYERGIFRYIH8iopUNBAHX209fVuGM0pEegADyZeqvkujKDUSkPoWdInkQA06IRmweu+7GOPonGs27CrRH5IDJFtVnUXkAWAqQT+kBKRVLOiL1IAahLuAAT0RQlj2Xdd0A+t39uTHGy1bkhFAexfIE5GcPiqYgGooQGNVAAAAAElFTkSuQmCC");
}
.ms-spoiler-trigger > span {
padding: 0 3px;
}
.ms-spoiler-trigger:hover > span {
border-bottom-style: solid;
}
.ms-lots .ms-lot:hover .ms-lot__tool .ms-lot-view {
display: block;
}
.ms-lots .ms-lot .ms-lot__content {
min-height: initial;
padding-bottom: 10px;
}
.ms-lots .ms-lot .ms-lot__tool {
width: 100%;
position: relative;
}
.ms-lots .ms-lot .ms-lot__tool .ms-lot-view {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
color: #b7b7b7;
font-size: 12px;
font-weight: 400;
text-transform: uppercase;
display: none;
}
.ms-lots .ms-lot .ms-lot__tool .ms-lot-view::after {
content: '';
display: inline-block;
height: 14px;
/*background-image: url("../img/sprite.svg#eye");*/
background-position: center;
background-repeat: no-repeat;
background-size: cover;
width: 25px;
margin-left: 6px;
position: relative;
top: 3px;
}
.ms-visible.spoiler-trigger + div {
display: block;
}
.ms-spoiler-trigger {
color: #999999;
font-size: 16px;
font-weight: 400;
line-height: 40px;
text-decoration: none;
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAALCAMAAABFyS02AAAAAXNSR0IB2cksfwAAADNQTFRFAAAAYGBgZWVlaGhoZWVlZWVlZmZmZmZmZWVlZ2dnZ2dnZmZmZmZmZmZmZmZmZmZmZmZmdm5wIgAAABF0Uk5TABA/IDCw/89gkJ/woO/QUK9g+KnVAAAAT0lEQVR4nFXNSRKAMAhE0cZgG00c7n9aIVYhYdX1Fh/IgnxFgZVbkkoqdvIIUbIJ0H/Tk019hIV4blgSyOVmwjuqbo9JTb/dZvlsFrMenRftQgJMTlIEIQAAAABJRU5ErkJggg==") no-repeat 100% 50%;
}
.ms-spoiler-trigger.active {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAKCAYAAABSfLWiAAAAkElEQVQoU43SwQ2DMAwF0PwswCrtBozACPTgLOUDHYERGIFRYIH8iopUNBAHX209fVuGM0pEegADyZeqvkujKDUSkPoWdInkQA06IRmweu+7GOPonGs27CrRH5IDJFtVnUXkAWAqQT+kBKRVLOiL1IAahLuAAT0RQlj2Xdd0A+t39uTHGy1bkhFAexfIE5GcPiqYgGooQGNVAAAAAElFTkSuQmCC");
}
.ms-spoiler-trigger > span {
padding: 0 3px;
}
.ms-spoiler-trigger:hover > span {
border-bottom-style: solid;
}
.ms-visible {
display: none;
}
.selection_type {
padding: 10px;
border: 2px solid #dcdee2;
color: #1d2945;
display: table-cell;
width: 50%;
margin: 0 15px;
font-size: 0.9em;
cursor: pointer;
}
@media screen and (max-width: 1023px) {
.ms-tabs-content {
padding: 0 15px;
margin-bottom: 30px;
}
.ms-tabs-content > div {
display: block;
}
.ms-visible {
display: block;
}
.ms-hidden {
display: none;
}
.ms-visible.spoiler-trigger + .spoiler-block {
display: none;
}
.ms-visible.spoiler-trigger + .spoiler-block.active {
display: block;
}
.ms-spoiler-block {
display: none;
padding-top: 15px;
}
.ms-spoiler-block.active {
display: block;
}
.ms-spoiler-block .ms-hidden {
display: block;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment