Вы можете использовать атрибут data
на оверлеях и найти их, используя идентификаторы в атрибуте href
ваших кнопок.
$(document).ready(function() {
$('.button').on('click', onButtonClick);
$('.overlay').on('click', onOverlayClick);
function onButtonClick(event) {
event.preventDefault();
var button = $(event.target);
if (button.length) {
var targetData = button.attr('href').replace('#', '');
var overlay = $('.overlay[data-overlay="' + targetData + '"]');
toggleOverlay(overlay);
}
}
function onOverlayClick(event) {
var overlay = $(event.target);
toggleOverlay(overlay);
}
function toggleOverlay(overlay) {
if (overlay.length) {
overlay.toggleClass('active');
$('.content').toggleClass('smaller');
}
}
});
* {
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
-o-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
}
.intro {
height: 100%;
width: 100%;
}
.intro .content {
position: absolute;
top: 50%;
left: 50%;
width: 80%;
margin: -6em -40% 0;
display: block;
text-align: center;
}
.intro .content h1 {
font-size: 3em;
margin: 0;
color: #FFF;
}
.intro .content h2 {
font-size: 2em;
font-weight: 100;
margin: 0 0 2em;
color: rgba(255, 255, 255, 0.5);
}
.overlay {
opacity: 0;
visibility: hidden;
position: fixed;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.65);
z-index: 100;
-webkit-transform: scale(1.8);
-moz-transform: scale(1.8);
-o-transform: scale(1.8);
transform: scale(1.8);
}
.overlay.active {
opacity: 1;
visibility: visible;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
}
.overlay h1 {
color: white;
font-weight: bold;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.smaller {
-webkit-transform: scale(0.8);
-moz-transform: scale(0.8);
-o-transform: scale(0.8);
transform: scale(0.8);
-webkit-filter: blur(10px);
-moz-filter: blur(10px);
-o-filter: blur(10px);
-ms-filter: blur(10px);
filter: blur(10px);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.2/semantic.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="overlay" data-overlay="default">
<h1>This is the overlay content.</h1>
</div>
<div class="overlay" data-overlay="another">
<h1>This is another overlay content.</h1>
</div>
<div class="intro">
<div class="content">
<h1>Standard message about awesome thing</h1>
<a class="ui big inverted blue button" href="#default">FIND OUT MORE</a>
<a class="ui big inverted blue button" href="#another">FIND OUT ANOTHER</a>
</div>
</div>