【发布时间】:2012-09-16 08:35:10
【问题描述】:
我正在尝试在 DIV 中包含的 php 页面上使用 jQuery 或 CSS(或其他方式!)创建淡入淡出或滑动过渡。我四处搜索,发现了大量的淡入淡出转换的例子,它们使 div 相互淡化或淡入隐藏的内容,但这种情况略有不同。
我有一个 DIV,其内容由导航栏控制。选择时,每个页面都使用 PHP 成功包含在 div 中,但我想让内容淡入淡出。
关于如何在页面更改之间进行漂亮的过渡有什么想法吗?
非常感谢
代码:
<?php
if (isset($_GET['page']))
$page = $_GET['page'];
else {
$_GET['page'] = 1;
$page = $_GET['page'];
}
?>
然后页面被包含在一个 div 中,如下所示:
<div id="content">
<?php switch($page)
{
case "about":
include('includes/about.php');
break;
case "portfolio":
include('includes/portfolio.php');
break;
case "contact":
include('includes/contact.php');
break;
default:
include('includes/home.php');
}
?>
</div>
从导航栏中选择内容:
<ul>
<li><a href="m_index.php?page=home"><img src="" width="32" height="32" alt="Home"/></a></li>
<li><a href="m_index.php?page=about"><img src="" width="32" height="32" alt="About" /></a></li>
<li><a href="m_index.php?page=portfolio"><img src="" width="32" height="32" alt="Portfolio" /></a></li>
<li><a href="m_index.php?page=contact"><img src="" width="32" height="32" alt="Contact Us" /></a></li>
</ul>
【问题讨论】:
-
但是您是否使用 ajax 加载内容?否则,您的代码不会将内容加载到 DIV 中,而是重新加载整个页面。
-
据我所知,这只能通过 IE 实现:jansfreeware.com/articles/ie-page-transitions.html
-
可能是这样的? onextrapixel.com/2010/02/23/…
-
我添加了一个答案,有用吗?
标签: php jquery include fade transition