html - PDF 文件嵌入
问题描述
下面是带有标签的 HTML,用于将 PDF 文件发布到网页。我仍然无法使嵌入的 PDF 文件中心对齐。我尝试使用内联 CSS 将其居中对齐。你能帮我纠正我的 CSS 吗?此外,我还想知道是否有更好的方法将 PDF 文件嵌入网页中。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Style the body */
body {
font-family: Arial, Helvetica, sans-serif;
}
/* Header/logo Title */
.header {
padding: 80px;
text-align: center;
background: #1abc9c;
color: white;
}
/* Increase the font size of the heading */
.header h1 {
font-size: 40px;
}
/* Sticky navbar - toggles between relative and fixed, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed). The sticky value is not supported in IE or Edge 15 and earlier versions. However, for these versions the navbar will inherit default position */
.navbar {
overflow: hidden;
background-color: #333;
position: sticky;
position: -webkit-sticky;
top: 0;
}
/* Style the navigation bar links */
.navbar a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 20px;
text-decoration: none;
}
/* Right-aligned link */
.navbar a.right {
float: right;
}
/* Change color on hover */
.navbar a:hover {
background-color: #ddd;
color: black;
}
/* Active/current link */
.navbar a.active {
background-color: #666;
color: white;
}
/* Footer */
.footer {
padding: 20px;
text-align: center;
background: #ddd;
}
/* Responsive layout - when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 700px) {
.row {
flex-direction: column;
}
}
/* Responsive layout - when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other */
@media screen and (max-width: 400px) {
.navbar a {
float: none;
width: 100%;
}
}
</style>
</head>
<body>
<div class="header">
<h1>My Website</h1>
<p>A <b>responsive</b> website created by me.</p>
</div>
<div class="navbar">
<a href="#" class="active">Home</a>
<a href="#">Link</a>
<a href="#">Link</a>
<a href="#" class="right">Link</a>
</div>
<div class="main">
<h2>TITLE HEADING</h2>
<p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>
</div>
<div style="align:center">
<embed src="C:\Users\pramo\Desktop\Work\PwP\MiiR_Impact_Report_2020.pdf" type="application/pdf" width="840px" height="600px">
</div>
<div class="footer">
<h2>Footer</h2>
</div>
</body>
</html>
解决方案
推荐阅读
- c# - 无法将类型为“Newtonsoft.Json.Linq.JObject”的对象转换为类型“System.Collections.Generic.Dictionary`2[System.String,System.Object]”
- mysql - API 一次应该只返回 n 行
- flutter-layout - Flutter PageView 和 AudioPlayers
- mysql - 如何在 Docker 启动时自动选择 MySQL 数据库?
- grafana - Grafana - 使用 Prometheus(动态)属性/标签数据创建包含列值的表
- c# - 如何在wpf的datagridview中显示任何月份的所有日期
- android - 如何将待处理的意图转换为字节 []
- mysql - 如何使用 mysql 计算超过 1000:00:00 的时间总和
- vba - 在 Outlook 中设置会议时包括 Microsoft 团队会议
- html - 如何将数据从 html 传递到 django 视图以在 URL 中使用?