Query staff with modal support, needs unique acf id to properly work.
Display based on WP Pagebuilder Theme
<style>
/* The Modal (background) */
.modal<?php echo the_sub_field('modal_id'); ?> {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
}
/* The Close Button */
.close<?php echo the_sub_field('modal_id'); ?> {
color: #f27d02;
float: right;
font-size: 35px;
font-weight: bold;
}
.close<?php echo the_sub_field('modal_id'); ?>:hover,
.close<?php echo the_sub_field('modal_id'); ?>:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
.modalBtn {
border: 0px;
padding: 0px;
background: none;
color: #f27d02;
text-decoration: underline;
}
</style>
<div class="wpbf-medium-1-4 staffmember">
<?php if (get_sub_field('bild')): ?>
<img src="<?php the_sub_field('bild');?>" />
<?php endif;?>
<h3>
<?php echo get_sub_field('namn'); ?>
</h3>
<p>
<?php echo get_sub_field('sektor'); ?> <br>
<?php echo get_sub_field('telefon'); ?> <br>
<a href="mailto:<?php echo get_sub_field('e-post'); ?>"><?php echo get_sub_field('e-post'); ?></a><br>
</p>
<!-- The Modal -->
<div id="myModal<?php echo get_sub_field('modal_id'); ?>" class="modal<?php echo get_sub_field('modal_id'); ?>">
<!-- Modal content -->
<div class="modal-content">
<!-- Modal close -->
<span class="close<?php echo the_sub_field('modal_id'); ?>">×</span>
<h3>
<?php echo get_sub_field('namn'); ?>
</h3>
<p>
<?php echo get_sub_field('sektor'); ?> <br>
<?php echo get_sub_field('telefon'); ?> <br>
<a href="mailto:<?php echo get_sub_field('e-post'); ?>"><?php echo get_sub_field('e-post'); ?></a><br>
<?php echo the_sub_field('beskrivning'); ?>
</p>
</div>
</div>
<!-- Trigger/Open The Modal -->
<?php if( get_sub_field('namn') ): ?>
<button id="myBtn<?php echo get_sub_field('modal_id'); ?>" class="modalBtn">Läs mer</button>
<?php endif; ?>
<script>
// Get the modal
var modal<?php echo get_sub_field('modal_id'); ?> = document.getElementById("myModal<?php echo get_sub_field('modal_id'); ?>");
// Get the button that opens the modal
var btn = document.getElementById("myBtn<?php echo get_sub_field('modal_id'); ?>");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close<?php echo the_sub_field('modal_id'); ?>")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal<?php echo get_sub_field('modal_id'); ?>.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal<?php echo get_sub_field('modal_id'); ?>.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal<?php echo get_sub_field('modal_id'); ?>) {
modal<?php echo get_sub_field('modal_id'); ?>.style.display = "none";
}
}
</script>
</div>