2016-11-23 1 views
0

J'essaye de mettre un modal sur un site Web que je fais qui a un pdf incorporé.Modal avec pdf incorporé

Le pdf apparaît vraiment petit. Je n'ai pas écrit ce code à partir de zéro. Je l'ai trouvé sur un autre site. Quelqu'un peut-il aider? J'utilise le framework Zurb Foundation, FYI.

https://jsfiddle.net/8ryeqfbc/

HTML ----

<section class="modal"> 
      <div class="wrap row small-up-1 medium-up-1"> 
       <div class="special column"><h3>Modal</h3> 
        <!-- Trigger/Open The Modal --> 
         <button id="myBtn">View Full Menu</button> 

         <!-- The Modal --> 
         <div id="myModal" class="modal"> 

         <!-- Modal content --> 
         <div class="modal-content"> 
          <span class="close">x</span> 
          <iframe src="pdf.pdf"></iframe> 
         </div> 
        </div> 
       </div>    
      </div> 
    </section> 

Javascript ---

<script> 
// Get the modal 
var modal = document.getElementById('myModal'); 

// Get the button that opens the modal 
var btn = document.getElementById("myBtn"); 

// Get the <span> element that closes the modal 
var span = document.getElementsByClassName("close")[0]; 

// When the user clicks on the button, open the modal 
btn.onclick = function() { 
    modal.style.display = "block"; 
} 

// When the user clicks on <span> (x), close the modal 
span.onclick = function() { 
    modal.style.display = "none"; 
} 

// When the user clicks anywhere outside of the modal, close it 
window.onclick = function(event) { 
    if (event.target == modal) { 
     modal.style.display = "none"; 
    } 
} 
</script> 

CSS -----

* The Modal (background) */ 
.modal { 
    display: none; /* Hidden by default */ 
    position: fixed; /* Stay in place */ 
    z-index: 1; /* Sit on top */ 
    padding-top: 100px; /* Location of the box */ 
    left: 0; 
    top: 0; 
    width: 500px; /* Full width */ 
    height: 500px; /* 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 */ 
.modal-content { 
    position: relative; 
    background-color: #fefefe; 
    margin: auto; 
    padding: 0; 
    border: 1px solid #888; 
    width: 95%; 
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19); 
    -webkit-animation-name: animatetop; 
    -webkit-animation-duration: 0.4s; 
    animation-name: animatetop; 
    animation-duration: 0.4s 
} 

/* Add Animation */ 
@-webkit-keyframes animatetop { 
    from {top:-300px; opacity:0} 
    to {top:0; opacity:1} 
} 

@keyframes animatetop { 
    from {top:-300px; opacity:0} 
    to {top:0; opacity:1} 
} 

/* The Close Button */ 
.close { 
    color: white; 
    float: right; 
    font-size: 28px; 
    font-weight: bold; 
} 

.close:hover, 
.close:focus { 
    color: #000; 
    text-decoration: none; 
    cursor: pointer; 
} 

.modal-header { 
    padding: 2px 16px; 
    background-color: #5cb85c; 
    color: white; 
} 

.modal-body {padding: 2px 16px;} 

.modal-footer { 
    padding: 2px 16px; 
    background-color: #5cb85c; 
    color: white; 
} 

Répondre

1

style du iframe d'avoir ce fil l la boîte modale.

.modal-content iframe { 
    height: 100%; 
    width: 100%; 
}