[英]Css styles not applying to page
我有一個名為NEW的頁面,上面有一個from標記,它的頂部是一個包含我的樣式的外部頁面。 我鏈接該頁面上的樣式的方式與在另一頁面上相同,但是由於某些原因,即使在另一頁面上使用完全相同的路線,該樣式也未應用。 這可能是怎么回事?
樣式正常工作的頁面:
<% layout('partials/layout') -%>
<h1 class="heading">Pet Gallery!</h1>
<div class="blog-home2 spacer">
<div class="container gallery-container">
<div class="row m-t-40">
<% posts.forEach(function(post) { %>
<div class="col-md-4">
<div class="card" data-aos="flip-left" data-aos-duration="1200">
<!-- spot where image should go -->
<h1><%=post.name %></h1>
<span><%=post.fee %></span>
<span><%=post.description %></span>
<span><%= post.location%></span>
<div><a href="/gallery/pet/<%=post.id %>">View More</a></div>
</div>
</div>
<% }) %>
</div>
</div>
</div>
樣式不適用的頁面:
<% layout('partials/layout') -%>
<h1>New Pet</h1>
<form action="/gallery" method="POST" enctype="multipart/form-data">
<div>
<input type="text" name="post[name]" placeholder="Name">
</div>
<div>
<input type="text" name="post[fee]" placeholder="Rehoming Fee">
</div>
<div>
<textarea name="post[description]" placeholder="Description"></textarea>
</div>
<div>
<input type="text" name="post[location]"placeholder="Location">
</div>
<input type="file" accept='images/*' name="images" multiple>
</div>
<div>
<input type="submit">
</div>
[1]: https://i.stack.imgur.com/zjj7C.png
包含導航欄和樣式鏈接的代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><%= title %>></title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.47.0/mapbox-gl.css' rel='stylesheet' />
<link rel="stylesheet" href="stylesheets/post-show.css">
</head>
<body>
<% include ../partials/navbar %>
<% include ../partials/flash-message %>
<%-body -%>
</body>
</html>
<% layout('/partials/layout') -%>
有一個正斜杠。 這意味着瀏覽器將在域的頂層開始搜索。 因此,如果您的當前目錄為http://example.com/pages/
:
/partials/layout
將在http://example.com/partials/layout
搜索
而
partials/layout
將在http://example.com/pages/partials/layout
搜索
好吧,我終於能夠找出問題所在。 我在樣式表鏈接上的上缺少正斜杠。 仍然不確定哪一個適用於一頁,但不適用於其他頁面,但是問題解決了。 謝謝您的幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.