width_body = screen.width;
function benefits(evt, cityName) {
var i, tabcontent, tablinks, width;
tabcontent = document.getElementsByClassName("tabcontent");
width = (tabcontent[0].offsetWidth) / 2;
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.transform = "translateX(-500px)";
tabcontent[i].style.opacity = "0";
tabcontent[i].style.left = "calc(50% - "+width+"px)";
tabcontent[i].style.maxWidth = width_body+'px';
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.opacity = "1";
document.getElementById(cityName).style.transform = "translateX(0px)";
evt.currentTarget.className += " active";
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
.tabcontent {
display: block;
position:absolute;
-webkit-transition: .6s;
-o-transition: .6s;
transition: .6s;
margin:0px 30px 0px 0px;
}
- "при пролистывании верхний уходит и становится как бы фоном всего, второй на передний план и третий становится вторым маленьким".
при пролистывании верхний уходит и становится как бы фоном"
<a modal-win='modal_1' href='#'>Click me</a>
<a modal-win='modal_2' href='#'>Click me</a>
<div class='modal_bg'>
<div class='flex'>
<div class='modal_win modal_1'>Modal window 1</div>
<div class='modal_win modal_2'>Modal window 2</div>
</div>
</div>
.modal_bg {
position: fixed;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
background: #000;
display: none;
}
.flex {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
flex-wrap: wrap;
height:100%;
}
.modal_win {
display: block;
min-width: 300px;
min-height: 300px;
background: #fff;
text-align: center;
display: none;
}
$(document).on('click', "[modal-win]", function(event){
event.preventDefault();
var target = event.target;
var acbut = $(target).attr('modal-win');
$('.'+acbut).fadeIn(600);
$('.modal_bg').fadeIn(600);
});
$(document).on('click', ".modal_bg", function(event){
event.preventDefault();
event.stopPropagation();
var target = event.target;
var check = $(target).attr('class');
if(check == 'flex'){
$(this).fadeOut(600);
$('.modal_win').each(function (index, element) {
$(element).fadeOut(600);
});
}
});