页面在本地和jsfiddle上正常工作,但通过GitHub不正常。

huangapple go评论178阅读模式
英文:

page working fine locally and on jsfiddle but not through GitHub

问题

新手,也是第一次尝试。迄今为止,在工作中通过内部课程完成了数周的学习,我非常喜欢,我可以补充一下。但是通过实践,我尝试使用Bootstrap样式等创建了一个页面。我在页面上有一个手风琴和一个轮播,但在GitHub托管时,它们都无法正常工作。而且,当导航栏收缩时,汉堡按钮无法点击?在本地和jsfiddle上都能正常工作。我尝试了不同的CDN放置组合,但无法使任何东西正常工作。页面具有响应性,列似乎也正常工作。不确定下一步或需要共享什么,我猜测是我的代码?也许我只需复制并粘贴我的.html页面在这里?先谢谢了!

英文:

new here, and also new to the game. Weeks course done in house through work so far, loving it might i add. But through practice i have tried to create a page using bootstrap styling etc. I have an accordion on the page and also a carousel, neither work when hosted through git hub. Also when the navbar shrinks, the burger button is 'un-clickable'? Both work fine locally, and also on jsfiddle. Tried different combos of cdn placement but cant get anything working properly. Page has responsiveness, and columns seem to work fine. Not sure of next steps or what i need to share etc, im guessing my code? maybe i just c&p my .html page here? thanks in advance!

html:

  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">
  6. <title>Bootstrap & JavaScript</title>
  7. <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  8. <!-- My Style Sheet -->
  9. <link href="styles/bootstrap_page.css" rel="stylesheet" type="text/css" />
  10. </head>
  11. <body>
  12. <div style="padding-left: 15%; padding-right: 15%;">
  13. <!-- Navbar -->
  14. <nav class="navbar navbar-expand-lg navbar-light" style="background-color: #EEF0EB;">
  15. <div class="container-fluid">
  16. <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo03"
  17. aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
  18. <span class="navbar-toggler-icon"></span>
  19. </button>
  20. <a href="home.html"><img src="images/NE_logo (1).png" style="height: 70px; width: 70px;"></a>
  21. <div class="collapse navbar-collapse" id="navbarTogglerDemo03">
  22. <ul class="navbar-nav me-auto mb-2 mb-lg-0" style="font-size: 30px;">
  23. <li class="nav-item">
  24. <a class="nav-link" href="home.html">Home</a>
  25. </li>
  26. <li class="nav-item">
  27. <a class="nav-link" href="html.html">HTML</a>
  28. </li>
  29. <li class="nav-item">
  30. <a class="nav-link" href="html+css.html">HTML&CSS</a>
  31. </li>
  32. <li class="nav-item">
  33. <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">BS&JS</a>
  34. </li>
  35. <li class="nav-item">
  36. <a class="nav-link" href="boot_JS1.html">BS&JS1</a>
  37. </li>
  38. </ul>
  39. </div>
  40. </div>
  41. </nav>
  42. <!-- header section -->
  43. <div class="container" style="font-family: Dongle; color: #153243; text-align: center;">
  44. <div class="page-header">
  45. <h1 style="font-size: 80px;">Made using HTML, CSS, Bootstrap and JavaScript</h1>
  46. </div>
  47. <hr>
  48. <p style="padding: 0; font-size: 40px;">This is a responsive webpage. Meaning that it will automatically adjust
  49. for different screen sizes and viewports. Change your window size to see how it 'reponds'.</p>
  50. </div>
  51. <br>
  52. <!-- accordian -->
  53. <div class="accordion" id="bootsrap_accordion">
  54. <div class="accordion-item">
  55. <h2 class="accordion-header" id="panelsStayOpen-headingOne">
  56. <button class="accordion-button" type="button" data-bs-toggle="collapse"
  57. data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne"
  58. style="font-size: 50px; color: #153243; background-color: #B4B8AB;">
  59. The Accordian
  60. </button>
  61. </h2>
  62. <div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show"
  63. aria-labelledby="panelsStayOpen-headingOne" data-bs-parent="bootsrap_accordion">
  64. <div class="accordion-body" style="font-size: 25px;">
  65. <strong>This is the body of the accordian. This first accordian body is shown by default, unless specified
  66. by
  67. the stylesheet otherwise. </strong>
  68. <p>The rest of the accordian can all be opened, and the window will remain open, until the header is clicked
  69. again to close it. This is another button style added externally through Bootstraps CSS. Also, the blue
  70. hue has been removed through CSS that is normally present (for accessibility reasons) when a header of an
  71. accordian is clicked.
  72. Removed on the external stylesheet: <br>
  73. <kbd style="font-size: 14px; padding: 0; background-color: #153243;">: focus { <br>
  74. outline: 0 !important; <br>
  75. box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important; <br>
  76. }
  77. </kbd>
  78. </p>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="accordion-item">
  83. <h2 class="accordion-header" id="panelsStayOpen-headingTwo">
  84. <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
  85. data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false"
  86. aria-controls="panelsStayOpen-collapseTwo"
  87. style="font-size: 50px; color: #153243; background-color: #B4B8AB; background-color: #B4B8AB;">
  88. Paragraph Two
  89. </button>
  90. </h2>
  91. <div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse"
  92. aria-labelledby="panelsStayOpen-headingTwo" data-bs-parent="bootsrap_accordion">
  93. <div class="accordion-body" style="font-size: 25px;">
  94. Donec convallis nulla eget metus posuere, ut viverra turpis tristique. Ut volutpat est id sapien dignissim,
  95. eu interdum ex ornare. Phasellus auctor posuere neque, eu lacinia felis dapibus ac. Nunc porttitor, lacus
  96. nec condimentum rutrum, felis neque sollicitudin velit, sed pharetra massa mi quis massa. Morbi auctor felis
  97. diam, id tincidunt mauris dignissim vitae. Sed tincidunt sit amet felis eget vulputate. Mauris bibendum
  98. condimentum tincidunt. Pellentesque nulla ligula, porttitor in quam at, vehicula facilisis urna. Suspendisse
  99. molestie, libero et hendrerit porta, risus libero vehicula turpis, at mollis massa nulla in velit. Quisque
  100. ut gravida elit, molestie accumsan ante.
  101. </div>
  102. </div>
  103. </div>
  104. <div class="accordion-item">
  105. <h2 class="accordion-header" id="panelsStayOpen-headingThree">
  106. <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
  107. data-bs-target="#panelsStayOpen-collapseThree" aria-expanded="false"
  108. aria-controls="panelsStayOpen-collapseThree"
  109. style="font-size: 50px; color: #153243; background-color: #B4B8AB;">
  110. Paragraph Three
  111. </button>
  112. </h2>
  113. <div id="panelsStayOpen-collapseThree" class="accordion-collapse collapse"
  114. aria-labelledby="panelsStayOpen-headingThree" data-bs-parent="bootsrap_accordion">
  115. <div class="accordion-body" style="font-size: 25px;">
  116. Sed eget arcu tristique felis venenatis convallis in non magna. Praesent justo felis, bibendum vel nisi
  117. accumsan, venenatis cursus quam. Phasellus efficitur augue erat. Curabitur condimentum hendrerit quam non
  118. maximus. In volutpat tellus vitae nisi vulputate efficitur. Duis sodales sagittis rutrum. In quis velit
  119. posuere, rhoncus neque in, suscipit enim. Aliquam condimentum magna at euismod sollicitudin. Duis nulla
  120. urna, bibendum et justo vel, ullamcorper pretium erat. Sed imperdiet, purus vitae vulputate maximus, est
  121. diam malesuada nibh, non blandit nulla ante in dolor. Donec venenatis elit sed consectetur pellentesque.
  122. </div>
  123. </div>
  124. </div>
  125. <div class="accordion-item">
  126. <h2 class="accordion-header" id="panelsStayOpen-headingFour">
  127. <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
  128. data-bs-target="#panelsStayOpen-collapseFour" aria-expanded="false"
  129. aria-controls="panelsStayOpen-collapseFour"
  130. style="font-size: 50px; color: #153243; background-color: #B4B8AB;">
  131. Paragraph Four
  132. </button>
  133. </h2>
  134. <div id="panelsStayOpen-collapseFour" class="accordion-collapse collapse"
  135. aria-labelledby="panelsStayOpen-headingFour" data-bs-parent="bootsrap_accordion">
  136. <div class="accordion-body" style="font-size: 25px;">
  137. Nunc eu dolor dignissim, tristique turpis tristique, viverra arcu. Nulla scelerisque cursus ex, nec finibus
  138. turpis scelerisque eget. In porta felis eget facilisis bibendum. Aliquam id mi consequat, porttitor velit
  139. convallis, tincidunt urna. Quisque placerat tellus non mauris eleifend iaculis. Vivamus porttitor velit
  140. nunc, id facilisis erat scelerisque eget. Nunc rutrum laoreet augue sed egestas. Phasellus eget est
  141. fringilla odio finibus volutpat maximus ut mauris. Morbi sollicitudin semper nunc eget fringilla. Nam
  142. gravida dictum urna, at ullamcorper quam sagittis convallis. Aenean consequat ipsum a arcu efficitur
  143. ultricies. Sed gravida turpis in turpis posuere, sed faucibus mi consectetur.
  144. </div>
  145. </div>
  146. </div>
  147. <br>
  148. <br>
  149. <hr>
  150. <br>
  151. <!-- Feature section-->
  152. <div class="container" style="font-family: Dongle; color: #153243; text-align: center;">
  153. <p style="padding: 0; font-size: 40px;">This next section is a responsive 'Feature' section. It uses Bootstrap's
  154. 12 column grid system to re-size and maneuver the text and images depending on the screen width. </p>
  155. </div>
  156. <br><br>
  157. <div class="row featurette" style="color: #153243; ">
  158. <div class="row">
  159. <div class="col-md-7 my-auto">
  160. <h1 style="font-size: 60px;"">Fred Again..</h1>
  161. <p style=" font-family: Dongle; color: #153243; font-size: 30px;">
  162. Frederick John Philip Gibson, known professionally as Fred Again or simply Fred, is a British record
  163. producer, singer, songwriter, multi-instrumentalist, and DJ.
  164. </p>
  165. </div>
  166. <div class="col-md-5">
  167. <img src="images/carousel/fred_again.jpg" class="featurette-image img-fluid mx-auto" width="500"
  168. height="500" style="border-radius: 2.5%;" />
  169. <rect width="100%" height="100%" fill="var(--bs-secondary-bg)" />
  170. </svg>
  171. </div>
  172. </div>
  173. </div>
  174. <br>
  175. <hr><br>
  176. <!-- new feature -->
  177. <div class="row featurette" style="color: #153243; font-family: Dongle;">
  178. <div class="row">
  179. <div class="col-md-7 order-md-2 my-auto">
  180. <h1 style="font-size: 60px;">Bicep</h1>
  181. <p style="font-family: Dongle; color: #284B63; font-size: 30px;">
  182. Bicep are an electronic music production and DJ duo from Belfast, Northern Ireland, consisting of Andrew
  183. Ferguson and Matthew McBriar. <br>
  184. </p>
  185. </div>
  186. <div class="col-md-5 order-md-1">
  187. <img src="images/carousel/bicep.jpg" class="featurette-image img-fluid mx-auto" width="500" height="500"
  188. style="border-radius: 2.5%;" />
  189. <rect width="100%" height="100%" fill="var(--bs-secondary-bg)" />
  190. </div>
  191. </div>
  192. </div>
  193. <br>
  194. <hr>
  195. <br>
  196. <!-- new feature -->
  197. <div class="row featurette" style="color: #153243; font-family: Dongle;">
  198. <div class="row">
  199. <div class="col-md-7 my-auto">
  200. <h1 style="font-size: 60px;">Dave</h1>
  201. <p style="font-family: Dongle; color: #284B63; font-size: 30px;">
  202. David Orobosa Omoregie (born 5 June 1998), also known as Dave, is an English rapper. He has gained acclaim
  203. for his socially conscious lyricism and wordplay.
  204. </p>
  205. </div>
  206. <div class="col-md-5">
  207. <img src="images/carousel/dave.jpeg" class="featurette-image img-fluid mx-auto" width="500" height="500"
  208. style="border-radius: 2.5%;" />
  209. <rect width="100%" height="100%" fill="var(--bs-secondary-bg)" />
  210. </svg>
  211. </div>
  212. </div>
  213. </div>
  214. <br>
  215. <br>
  216. <hr>
  217. <br>
  218. <!-- carousel -->
  219. <div class="container" style="font-family: Dongle; color: #153243; text-align: center;">
  220. <p style="padding: 0; font-size: 40px;">A simple carousel with <kbd
  221. style="font-size: 20px;">style="max-height...";</kbd> attributes to keep a consistant negative space from
  222. outer edge throughout the page.</p>
  223. </div>
  224. <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
  225. <div class="carousel-indicators">
  226. <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active"
  227. aria-current="true" aria-label="Slide 1"></button>
  228. <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"
  229. aria-label="Slide 2"></button>
  230. <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"
  231. aria-label="Slide 3"></button>
  232. </div>
  233. <div class="carousel-inner">
  234. <div class="carousel-item active">
  235. <img src="images/carousel/1.jpg" class="d-block w-100" style="max-height: 749px;" alt="...">
  236. </div>
  237. <div class="carousel-item">
  238. <img src="images/carousel/2.jpg" class="d-block w-100" style="max-height: 749px;" alt="...">
  239. </div>
  240. <div class="carousel-item">
  241. <img src="images/carousel/3.jpg" class="d-block w-100" style="max-height: 749px;" alt="...">
  242. </div>
  243. </div>
  244. <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators"
  245. data-bs-slide="prev">
  246. <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  247. <span class="visually-hidden">Previous</span>
  248. </button>
  249. <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators"
  250. data-bs-slide="next">
  251. <span class="carousel-control-next-icon" aria-hidden="true"></span>
  252. <span class="visually-hidden">Next</span>
  253. </button>
  254. </div>
  255. <br>
  256. <!-- footer -->
  257. <footer class="container-fluid bg-4"
  258. style="font-family: Arial, Helvetica, sans-serif; color: #153243; font-size: 15px;">
  259. <p style="float: right;"><a href="#">Back to top</a></p>
  260. <p style="float: left;">© Nik 2023 · <a href="#">Privacy</a> · <a href="#">Terms</a> ·
  261. <a href="you_had_to.html">DONT CLICK</a></p>
  262. </footer>
  263. <!-- scripts -->
  264. <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
  265. <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
  266. <script src="https://code.jquery.com/jquery-3.7.0.js" integrity="sha256-JlqSTELeR4TLqP0OG9dxM7yDPqX1ox/HfgiSLBj8+kM=" crossorigin="anonymous"></script>
  267. </body>
  268. </html>

css:

  1. @import url('https://fonts.googleapis.com/css2?family=Dongle:wght@300&display=swap');
  2. body {
  3. font: 20px Dongle;
  4. color: #EEF0EB;
  5. background-color: #EEF0EB;
  6. }
  7. .navbar .navbar-brand {
  8. display: inline-block;
  9. padding: 5px;
  10. border: 0;
  11. border-radius: 0;
  12. margin-bottom: 0;
  13. font-size: 12px;
  14. letter-spacing: 5px;
  15. display: flex;
  16. }
  17. .navbar-nav li a:hover {
  18. color: #153243 !important;
  19. font-size: 30px !important;
  20. }
  21. .navbar-brand img {
  22. height: 55;
  23. width: 55;
  24. margin-right: 20px;
  25. max-width: 50px;
  26. max-height: 50px;
  27. align-self: center !important;
  28. margin-top: 22px !important;
  29. }
  30. hr {
  31. border: 0;
  32. height: 1px;
  33. background-image: linear-gradient(to right, #B4B8AB, #153243, rgba(0, 0, 0, 0));
  34. }
  35. /* stops the accordian having a blue hue around clicked headers */
  36. :focus {
  37. outline: 0 !important;
  38. box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
  39. }
  40. .footer {
  41. color: inherit !important;
  42. }
  43. .featurette-divider {
  44. margin: 80px 0; /* Space out the Bootstrap <hr> more */
  45. }
  46. /* Thin out the marketing headings */
  47. .featurette-heading {
  48. font-weight: 300;
  49. line-height: 1;
  50. letter-spacing: -1px;
  51. }
  52. .featurette-heading {
  53. font-size: 50px;
  54. }
  55. }
  56. @media (min-width: 62em) {
  57. .featurette-heading {
  58. margin-top: 7rem;
  59. }

nothing working correctly

答案1

得分: 0

popper.min.jsbootstrap.min.js 都包含在 bootstrap.bundle.min.js 中,因此您不需要单独的 popper.min.js。我还应该说一下,Bootstrap 不再需要 jQuery,因此也不再需要它。

而且,我猜 htmlpreview.github.io/ 适用于基本的纯HTML文件,因此请尝试在像Github Pages这样的适当服务器上托管它。

英文:

Both popper.min.js and bootstrap.min.js are included in bootstrap.bundle.min.js therefore you don't need individual popper.min.js. I should also say that Bootstrap no longer requires jQuery therefore this's not needed either.

And I guess htmlpreview.github.io/ is for basic and vanilla HTML files therefore try to host it on a proper server like Github Pages.

huangapple
  • 本文由 发表于 2023年6月12日 06:40:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76452792.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定