gpt4 book ai didi

javascript - 带有嵌入式 pdf 的模态

转载 作者:太空宇宙 更新时间:2023-11-04 09:31:14 25 4
gpt4 key购买 nike

我正在尝试在我正在制作的具有嵌入式 PDF 的网站上放置一个模式。

pdf 显示得非常小。我没有从头开始编写这段代码。我在另一个网站上找到了它。谁能帮忙?

我正在使用 Zurb Foundation 框架,仅供引用。

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;
}

最佳答案

设置 iframe 的样式以使其填充模态框。

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

关于javascript - 带有嵌入式 pdf 的模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40772400/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com