php - 内部链接到列表中的子项

标签 php jquery html css mysql

使用 fullPage.js(一个 jQuery 滚动菜单),我有以下情况:

我有一个无序列表 - 其来源是一个 SQL 数据库(使用 PHP 回显)。

每页只有两个元素被回显。

在页面顶部,我有一个简单的菜单:

<a href="#theList:first-child">First Item</a>
<a href="#theList:last-child">Second Item.</A>

我想链接到列表中的第一项和第二项。

在 PHP 之前,我有以下内容:

<a name="theList">

我必须设置 .. 但我如何定位列表中的不同 child ?

让我感到困惑——如果有人能提供帮助,我将非常感谢!

最佳答案

fullPage.js 的正确使用方法应该是:

1 .有一个带有 data-menuanchor 的菜单:

<ul id="menu">
  <li data-menuanchor="theList1"><a href="#theList1">First slide</a></li>
  <li data-menuanchor="theList2"><a href="#theList2">Second slide</a></li>
  <li data-menuanchor="theList3"><a href="#theList3">Third slide</a></li>
  <li data-menuanchor="theList4"><a href="#theList4">Fourth slide</a></li>
</ul>

2 .config with js: anchors: ['theList1', 'theList2', 'theList3', 'theList4'],

3 .给样式添加CSS规则

$('#fullpage').fullpage({
  sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
  anchors: ['theList1', 'theList2', 'theList3', 'theList4'],
  menu: '#menu',
  slidesNavigation: true
});
@CHARSET "ISO-8859-1";
/* Reset CSS
 * --------------------------------------- */
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,
form,fieldset,input,textarea,p,blockquote,th,td {
    padding: 0;
    margin: 0;
}
a{
	text-decoration:none;
}
table {
    border-spacing: 0;    
}
fieldset,img {
    border: 0;
}
address,caption,cite,code,dfn,em,strong,th,var {
    font-weight: normal;
    font-style: normal;
}
strong{
	font-weight: bold;
}
ol,ul {
    list-style: none;
    margin:0;
    padding:0;
}
caption,th {
    text-align: left;

}
h1,h2,h3,h4,h5,h6 {
    font-weight: normal;
    font-size: 100%;
    margin:0;
    padding:0;
    color:#444;
}
q:before,q:after {
    content:'';
}
abbr,acronym { border: 0;
}


/* Custom CSS
 * --------------------------------------- */
body{
	font-family: arial,helvetica;
	color: #333;
	color: rgba(0,0,0,0.5);
}
.wrap{
	margin-left: auto;
	margin-right: auto;
	width: 960px;
	position: relative;
}
h1{
	font-size: 6em;	
}
p{
	font-size: 2em;
}
.intro p{
	width: 50%;
	margin: 0 auto;
	font-size: 1.5em;
}
.section{
	text-align:center;
}
#menu li {
	display:inline-block;
	margin: 10px;
	color: #000;
	background:#fff;
	background: rgba(255,255,255, 0.5);
	-webkit-border-radius: 10px; 
            border-radius: 10px; 
}
#menu li.active{
	background:#666;
	background: rgba(0,0,0, 0.5);
	color: #fff;
}
#menu li a{
	text-decoration:none;
	color: #000;
}
#menu li.active a:hover{
	color: #000;
}
#menu li:hover{
	background: rgba(255,255,255, 0.8);
}
#menu li a,
#menu li.active a{
	padding: 9px 18px;
	display:block;
}
#menu li.active a{
	color: #fff;
}
#menu{
	position:fixed;
	top:0;
	left:0;
	height: 40px;
	z-index: 70;
	width: 100%;
	padding: 0;
	margin:0;
}
.twitter-share-button{
	position: fixed;
	z-index: 99;
	right: 149px;
	top: 9px;
}
#download{
	margin: 10px 0 0 0;
	padding: 15px 10px;
	color: #fff;
	text-shadow: 0 -1px 0 rgba(0,0,0,0.25);
	background-color: #49afcd;
	background-image: -moz-linear-gradient(top, #5bc0de, #2f96b4);
	background-image: -ms-linear-gradient(top, #5bc0de, #2f96b4);
	background-image: -webkit-gradient(linear,0 0,0 100%,from( #5bc0de),to( #2f96b4));
	background-image: -webkit-linear-gradient(top, #5bc0de, #2f96b4);
	background-image: -o-linear-gradient(top, #5bc0de, #2f96b4);
	background-image: linear-gradient(top, #5bc0de, #2f96b4);
	background-repeat: repeat-x;
	filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#5bc0de', endColorstr='#2f96b4', GradientType=0);
	border-color: #2f96b4 #2f96b4 #1f6377;
	border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);
	filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
	
	-webkit-border-radius: 6px;
	-moz-border-radius: 6px;
	border-radius: 6px;
	vertical-align: middle;
	cursor: pointer;
	display: inline-block;
	-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
	-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);
}
#download a{
	text-decoration:none;
	color:#fff;
}
#download:hover{
	text-shadow: 0 -1px 0 rgba(0,0,0,.25);
	background-color: #2F96B4;
	background-position: 0 -15px;
	-webkit-transition: background-position .1s linear;
	-moz-transition: background-position .1s linear;
	-ms-transition: background-position .1s linear;
	-o-transition: background-position .1s linear;
	transition: background-position .1s linear;
}
#infoMenu{
	height: 20px;
	color: #f2f2f2;
	position:fixed;
	z-index:70;
	bottom:0;
	width:100%;
	text-align:right;
	font-size:0.9em;
	padding:8px 0 8px 0;
}
#infoMenu ul{
	padding: 0 40px;
}
#infoMenu li a{
	display: block;
	margin: 0 22px 0 0;	
	color: #333;
}
#infoMenu li a:hover{
	text-decoration:underline;
}
#infoMenu li{
	display:inline-block;
	position:relative;
}
#examplesList{
	display:none;
	background: #282828;
	-webkit-border-radius: 6px;
	-moz-border-radius: 6px;
	border-radius: 6px;
	padding: 20px;
	float: left;
	position: absolute;
	bottom: 29px;
	right: 0;
	width:638px;
	text-align:left;
}
#examplesList ul{
	padding:0;
}
#examplesList ul li{
	display:block;
	margin: 5px 0;
}
#examplesList ul li a{
	color: #BDBDBD;
	margin:0;
}
#examplesList ul li a:hover{
	color: #f2f2f2;
}
#examplesList .column{
	float: left;
	margin: 0 20px 0 0;
}
#examplesList h3{
	color: #f2f2f2;
	font-size: 1.2em;
	margin: 0 0 15px 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.4);
	-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
	-moz-box-shadow: 0 1px 0 rgba(255,255,255,0.1);
	box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
	padding: 0 0 5px 0;
}



/* Demos Menu
 * --------------------------------------- */
 #demosMenu{
	position:fixed;
	bottom: 10px;
	right:10px;
	z-index: 999;
 }
<link href="https://rawgit.com/alvarotrigo/fullPage.js/master/jquery.fullPage.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/alvarotrigo/fullPage.js/master/jquery.fullPage.js"></script>

<ul id="menu">
  <li data-menuanchor="theList1"><a href="#theList1">First slide</a></li>
  <li data-menuanchor="theList2"><a href="#theList2">Second slide</a></li>
  <li data-menuanchor="theList3"><a href="#theList3">Third slide</a></li>
  <li data-menuanchor="theList4"><a href="#theList4">Fourth slide</a></li>
</ul>

<div id="fullpage">
  <div class="section" id="section0">One</div>
  <div class="section" id="section1">
    <div class="slide">Two 1</div>
    <div class="slide">Two 2</div>
  </div>
  <div class="section" id="section2">Three</div>
  <div class="section" id="section3">Four</div>
</div>

关于php - 内部链接到列表中的子项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44269701/

相关文章:

php - 在 ubuntu 上使用 VS Code 进行 Xdebug 无法正常工作

Javascript向具有相同类的元素添加样式

php - 在 Codeigniter 中使用 jQuery 将选项添加到 DropDownList

jquery - 使用 withCredentials 和客户端证书的 jQuery 的 CORS 请求失败

html - Assets 管道,如何将图像路径添加到背景 : url()?

php - Facebook 应用程序 - 不请求获取用户数据的权限

php - Symfony2 自动生成的 HTML5 约束不起作用

php - 删除 VSCode PHP 调试中的字符限制

javascript - 如何将占位符设置为选择框

html - 对齐表格 html 中的文本