Reputation: 2307
I have 2 pages as of now. What I am doing is, I am trying page transition and I am using below plugin swup. Now my issue is page transition is not working when I click on the menu.
I added menu like /index
and /about
in href and my URL is
http://localhost:8080/example/index
and when I click on menu then I am getting object not found
and URL is showing http://localhost:8080/about
can anyone help me out with this issue?
header.php
<header>
<div>
<ul>
<li><a href="/index">Index</a></li>
<li><a href="/about">About</a></li>
</ul>
</div>
</header>
Index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<link href="assets/css/style.css">
</head>
<body>
<?php include('assets/include/header.php');?>
<div id="swup" class="transition-fade">
<h1>This is homepage</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
<script src="https://unpkg.com/swup@latest/dist/swup.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
about.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About Document</title>
<link href="assets/css/style.css">
</head>
<body>
<?php include('assets/include/header.php');?>
<div id="swup" class="transition-fade">
<h1>This is Aboutpage</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
<script src="https://unpkg.com/swup@latest/dist/swup.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
style.css
.transition-fade {
transition: 0.4s;
opacity: 1;
}
html.is-animating .transition-fade {
opacity: 0;
}
main.js
import Swup from 'swup';
const swup = new Swup();
Upvotes: 0
Views: 2641
Reputation: 1
Your links are wrong and basically lead to a pages that don't exist.
Change your menu links to:
<li><a href="/example/index">Index</a></li>
<li><a href="/example/about">About</a></li>
Upvotes: 0