index.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  7. <title>Document</title>
  8. <style>
  9. * {
  10. padding: 0;
  11. margin: 0;
  12. }
  13. @font-face {
  14. font-family: 'pglh';
  15. src: url(./fonts/汉仪全唐诗简.ttf);
  16. }
  17. #page {
  18. width: 800px;
  19. height: 1280px;
  20. font-size: 30px;
  21. text-align: center;
  22. position: relative;
  23. }
  24. #page > div {
  25. position: absolute;
  26. left: 0;
  27. right: 0;
  28. font-family: 'pglh';
  29. text-shadow: 2px 2px 3px #4f4f4f;
  30. color: white;
  31. }
  32. #title {
  33. top: 20%;
  34. font-size: 80px;
  35. }
  36. #author {
  37. bottom: 20%;
  38. text-align: right;
  39. padding-right: 30px;
  40. font-size: 55px;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <!-- 免费大图 http://tu.763g.com/bizhi/ -->
  46. <div id="page">
  47. <div id="title">这是一张封面</div>
  48. <div id="author">作者</div>
  49. </div>
  50. <script>
  51. const $page = document.getElementById('page');
  52. $page.style.backgroundImage = `url('image/${Math.round(Math.random() * 10)}.jpg')`;
  53. $page.style.backgroundPosition = 'center';
  54. $page.style.backgroundSize = 'cover';
  55. $page.style.backgroundRepeat = 'no-repeat';
  56. </script>
  57. </body>
  58. </html>