首先根据创建滑块的要求,我发现以下链接 Reference 1

我已经成功实现了,但是当我们开始使用asp.net代码时,它开始创建问题。但是我能够解决很多问题,但是我已经陷入困境。我想要你的指导。

问题:一旦用户自动提交子页面1的form1,我想移动“子页面内容2”。
我可以跳转到标签页2,但是不能使用jquery自动将页面内容1的内容移动到左边。

为了解决这个问题,我在这里找到了很多线程,给出了jquery ui选项卡小部件的解决方案。不过我想了解下面写的代码结构。

<div class="main_main_container">
  <div id="linktoPage1">
    <div id="linktoPage2">
        <div id="linktoPage3">
            <div id="linktoPage4">
                <nav> <a href="#linktoPage1">Page1</a><a href="#linktoPage2">Page2</a><a href="#linktoPage3">Page3</a><a 

href="#linktoPage4"></nav>
                <div class="Pages">
                        <div class="page" id="subPage1"> Sub Page Content 1 
            full flag asp.net form1
        </div>  
                        <div class="page" id="subPage2"> Sub Page Content 2
            full flag asp.net form2
         </div>
                        <div class="page" id="subPage3"> Sub Page Content 3 
            full flag asp.net form3
        </div>
                        <div class="page" id="subPage4"> Sub Page Content 4 
            full flag asp.net form4
        </div> 
                </div>  
            </div>
        </div> 
    </div> 
  </div>
</div>

此代码与Reference 1定义的代码相同

为了理解这个代码结构,我已经从以下页面中获得了帮助
w3org_site, vanseocom,tympanus_web

在w3org网站上,我发现以下几点帮助我了解上述HTML代码。

(as described on the w3org)

目的地锚点

<p> <a href="#section1"> History Notes </a>     
    <a href="#section2"> Maths Notes </a>     
    <a href="#section3"> Social Science Notes </a>
         </p>

Method 1:

<H2><A name="section1">History Notes </A></H2>
    ...section 1...
    <H2><A name="section2">Maths Notes </A></H2>
    ...section 2...

要么

Method 2:

我们可以通过使头元素本身成为锚点来实现相同的效果:

<H2 id="section1">History Notes </A></H2>
    ...section 1...
    <H2 id="section2">Maths Notes </A></H2>
    ...section 2...

现在这个描述使我对w3org上描述的代码感到困惑,因为它与参考文献1网站中描述的代码完全不同。

为什么他们没有使用#character来引导(发送)用户的链接历史记录的描述。
为什么在Reference 1作者的代码中写道:< div id =“linktoPage1”>并写入< a href =“#linktoPage1”>内部/嵌套< div id =“linktoPage4”>

这是一种特殊类型的cssistry(化学)在这里,我无法掌握。

我希望一旦我能够理解上述cssistry,我将会找到以下问题的答案。以上也已经描述过。

作者正在使用css方式将用户指向指定的位置。那么我们如何使用jquery来执行相同的操作。我的意思是我们如何编写#linktoPage1的等效代码:target .page(left:-100%);使用jquery。

谢谢!

解决方法

您使用的标签菜单的设计是为了不能使用JS选择选项卡。

菜单的工作原理是,所有的元素都包含在三个包装器中,其中一个是通过点击一个链接来定位的。这些页面是基于哪个包装元素被定位的样式。问题是您无法使用JS定位元素,这就是为什么您无法使用JS与当前代码选择标签。

但不用担心,这样做只是CSS的选项卡的一个糟糕的方法。如果按照您所引用的教程中所示的方式执行此操作,则在用户单击其中一个选项卡之前,最初没有选项卡被选中。此外,它需要大量的额外标记。

我建议您使用单选按钮(如果您希望标签菜单导航纯粹使用CSS工作,尽管使用JS的其他一些事情)。使用单选按钮的优点:

>你可以使用JS来选择一个选项卡,使用element.checked = true;
>您可以使用checked属性预先选择一个选项卡
>你的HTML的标记越来越少了
>仍然是纯CSS的解决方案

我已经创建了一个功能选项卡(),您可以使用它来选择一个选项卡。例如,选项卡(3)将选择第三个选项卡。

我试图在下面的代码的注释中尽可能多的细节。但是我明白,CSS选择器需要很好的了解才能充分理解,所以问问题是不清楚的。

/*
With the following function you can select a tab to be displayed:
tab(1) selects the first tab for instance.
*/
function tab(number){
    var elems=document.getElementsByTagName("input"),navs=[];
    for(var i=0;i<elems.length;i++) if(elems[i].getAttribute("name")=="nav") navs.push(elems[i]);
    navs[number-1].checked=true;
}
body {
    overflow-x: hidden;
    font-family: sans-serif;
    text-align: center;
}
/* 
You can select input elements whose name attribute is "nav" using 
the [attribute=value] selector to select all our radio buttons
that'll become the tabs:
*/
input[name=nav]{ 
    width: calc(100% / 3); /* third of the screen width */
    height: 40px;
    position: fixed;
    top: 0;
    left: 0;
    margin: 0;
    z-index: 2; /* this is so the ::before pseudo elements would be on top of the pages */
}
/*
To give separate styling for the second and the third tabs,you can use
the same selector again to target them specifically:
*/
input[value=i2]{
    left:calc(100% / 3);
}
input[value=i3]{
    left:calc(200% / 3);
}
/* 
Radio buttons can't be styled,but the trick is to create an ::after
pseudo element and place it on top of the radio button. When the user
clicks on a pseudo element,it activates its parent selecting it. So,in a nutshell,give the ::after pseudo element the styles you would for
the radio button. 
*/
input[name=nav]::after{
    content: attr(data-title); /* display the value of the data-title attribute inside the element. */
    display: block;
    position: absolute;
    top: 0; left: 0; /* Position it on top of its parent */
    width: 100%; height: 100%; /* Make it the size as its parent */
    padding: 5px;
    background-color: #111;
    cursor: pointer;
    font: 2em/1 helvetica,arial;
    font-weight: bold;
    color: #aaa;
    text-align: center;
    Box-sizing: border-Box;
    -webkit-transition: background 1s;
    -moz-transition: background 1s;
    transition: background 1s;
}
input[name=nav]:hover::after{ /* styling when hovering */
    background-color: #444;
}
input[name=nav]:checked::after{ /* styling when the tab is selected */
    background-color: red;
    color: #fff;
}
/*
Now the ::after pseudo elements are enough for the tabs to work,but if
you want to have the back and forward buttons,you should create these
::before pseudo elements also. They work with the same idea. This time however,their position is fixed so they can be placed on top of the pages.

Of course the back and forward buttons should only appear for tabs that 
aren't currently selected,for which you can use  the :not(:checked) selector:
*/
input[name=nav]:not(:checked)::before{
    content: '';
    display: block;
    position: fixed;
    top: 40px;
    left: 0;
    height: calc(100vh - 40px);
    width: 50vw;
}
input[value=i1]:not(:checked)::before{
    width:100vw;
}
input[value=i1]:checked ~ input[value=i3]::before{
    left:0;
}
input[value=i1]:checked ~ input[value=i2]::before{
    left:50vw;
}
input[value=i2]:checked ~ input[value=i3]::before{
    left:50vw;
}
.pages{
    position: fixed;
    z-index:1;
    top: 40px;
    left: 0;
    height: calc(100% - 40px);
    width: 100%;
    -webkit-transition: left 0.8s;
    -moz-transition: left 0.8s;
    transition: left 0.8s;
}
.page{
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
}
.page#1 {
    background-color: #bbb;
    left: 0;
}
.page#i2 {
    background-color: #ccc;
    left: 100%;
}
.page#i3 {
    background-color: #ddd;
    left: 200%;
}
/*
Finally,use the "after" ~ selector to determine which page to show. The idea here is 
that we first match which of the radio buttons are selected and then look for a .pages
element that follows it. This is the reason you shouldn't wrap the navigation elements
 - they need to be on the same level in the DOM tree.

So,for instance if the first tab is selected,then input[value=i1]:checked is matched
and we can style the .pages element with the ~ selector because it comes after the 
matched radio button in the DOM tree.
*/
input[value=i1]:checked ~ .pages {
    left: 0%;
}
input[value=i2]:checked ~ .pages {
    left: -100%;
}
input[value=i3]:checked ~ .pages {
    left: -200%;
}
<!-- This is the navigation. It needs to be on the same level as 
the pages in the DOM tree for the ~ selector to work,so don't 
wrap it. Put the title you want displayed in the data-title
attribute. -->
<input type="radio" name="nav" value="i1" data-title="Tab 1" checked>
<input type="radio" name="nav" value="i2" data-title="Tab 2">
<input type="radio" name="nav" value="i3" data-title="Tab 3">
<!-- And here are your pages: -->
<div class="pages">
    <div id="i1" class="page">
        <h1>Slide 1</h1>
    </div>
    <div id="i2" class="page">
        <h1>Slide 2</h1>
    </div>
    <div id="i3" class="page">
        <h1>Slide 3</h1>
    </div>
</div>

jquery – 如何用于导航目的的更多相关文章

  1. HTML5 input新增type属性color颜色拾取器的实例代码

    type 属性规定 input 元素的类型。本文较详细的给大家介绍了HTML5 input新增type属性color颜色拾取器的实例代码,感兴趣的朋友跟随脚本之家小编一起看看吧

  2. 移动HTML5前端框架—MUI的使用

    这篇文章主要介绍了移动HTML5前端框架—MUI的使用的相关资料,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

  3. jquery点赞功能实现代码 点个赞吧!

    点赞功能很多地方都会出现,如何实现爱心点赞功能,这篇文章主要为大家详细介绍了jquery点赞功能实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  4. 使用placeholder属性设置input文本框的提示信息

    这篇文章主要介绍了使用placeholder属性设置input文本框的提示信息,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下

  5. Bootstrap File Input文件上传组件

    这篇文章主要介绍了Bootstrap File Input文件上传组件,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  6. HTML5中input输入框默认提示文字向左向右移动的示例代码

    这篇文章主要介绍了HTML5中input输入框默认提示文字向左向右移动,本文通过实例代码给大家介绍的非常详细对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  7. 使用layui框架实现点击左侧导航切换右侧内容且右侧选项卡跟随变化的效果

    这篇文章主要介绍了基于HTML5实现点击左侧导航切换右侧内容且右侧选项卡跟随变化的效果,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  8. ios – 如何调整标签栏徽章位置?

    我在标签栏上显示徽章,但是当数字增加时,它会转到标签栏项目,如图所示我想稍微向左移动徽章视图,使其适合选定的选项卡image.i尝试如here所述,但没有运气.那么有没有办法调整徽章视图位置?任何帮助将不胜感激.解决方法我发现Kateryna的答案对于让我走上正轨非常有用,但我必须稍微更新一下:请注意,选项卡整数不是零索引,因此第一个选项卡将是数字1,第二个选项卡将是2,等等.

  9. ios – UITabBarController – Child(Tab)ViewControllers的不正确和不一致的边界

    我有一个带有两个选项卡的UITabBarController.每个选项卡都是UITableViewController.当UITabBarController出现时,两个选项卡视图都有不正确的边界.第一个选项卡正确位于导航栏下方,但延伸到底部的选项卡栏下方.第二个选项卡是另一种方式,从导航栏下方开始,但在底部的选项卡栏之前正确停止.我正在创建和呈现TabBarController,如下所示:然后在

  10. xcode – 隐藏或丢失构建阶段选项卡

    ..构建阶段选项卡.如何使用工具栏中的“构建阶段”选项卡显示布局,并将其保存以用于我的项目?顺便说一句,我使用XCode3.2可能是版本限制?解决方法听起来这些教程适用于Xcode4.对于您的版本,如果您在侧边栏中打开目标,则应该有一些组.这些是你的构建阶段.只需将库拖到类似“LinkExecutable”之类的库中,或单击复选框将其添加到目标,它应该自动进入.

随机推荐

  1. jquery-plugins – 是否可以使用猫头鹰旋转木马实现循环/无限轮播?

    我正在使用猫头鹰旋转木马,它的工作完美,除了它不支持循环/无限滚动.我没有搜索google和stackoverflow的想法,没有运气.有没有人在猫头鹰旋转木马上实现圆形/无限滚动?

  2. jQuery动态输入字段焦点

    我想使用以下jQuery向我的页面动态添加一个输入字段:在这样做之后,我希望输入字段具有闪烁的文本光标的焦点,所以我想在创建后立即输入.有人可以告诉我我该怎么办?

  3. jquery – 为什么$(window).height()这样错了?

    我试图获取当前浏览器的视口高度,使用但我得到的价值观太低了.当视口高度高达850px时,我从height()获取大约350或400像素的值.这是怎么回事?

  4. jquery – 如果在此div之外和其他draggables内部(使用无效和有效的还原选项),则可拖动恢复

    例如这样但是由于明显的原因,这不行.我可以说这个吗?

  5. 创建一个jQueryUI 1.8按钮菜单

    现在jQueryUI1.8已经出来了,我正在浏览更新,并且遇到了新的Buttonwidget,特别是SplitButtonwithadropdown的演示之一.这个演示似乎表明Buttonwidget可以在这里创建一个下拉菜单.作为讨论的问题,我想知道使用这个新的Button小部件来创建一个下拉菜单有什么方法.干杯.解决方法您必须在按钮下方列出一个列表,方式类似于此处为自动完成提供的演示:http

  6. 灰色divs使用JQuery

    我试图使用这个代码:为了淡出一大堆名为MySelectorDiv的div,唯一的是,它只会淡出第一个而不是所有的div,为什么呢?

  7. 使用jQuery动态插入到列表中

    我有两个订单列表在彼此旁边.当我从一个列表中选出一个节点时,我想按照字母顺序插入到另一个列表中.抓住的是我想要把一个元素放在另一个列表中,而不刷新整个列表.奇怪的是,当我插入到右边的列表中,它工作正常,但是当我插入到左边的列表中时,顺序永远不会出来.我也尝试将所有内容读入数组,并将其排序在一起,以防止children()方法没有按照显示顺序返回任何东西,但是我仍然得到相同的结果.这是我的jQuer

  8. 没有回应MediaWiki API使用jQuery

    我试图从维基百科获取一些内容作为JSON:但我没有回应.如果我粘贴到浏览器的地址栏,就像我得到预期的内容.怎么了?解决方法您需要通过添加&callback=?来触发具有$.getJSON()的JSONP行为?在querystring上,像这样:Youcantestithere.没有使用JSONP,你正在击中same-originpolicy,阻止XmlHttpRequest获取任何数据.

  9. jQuery Ajax请求每30秒

    我有这段代码,但是有些人在我的网站上的值可能会改变.我需要每30秒钟更新一次#financediv.这可以做吗解决方法您可以将代码放在单独的函数中,如下所示:然后每30秒建立一个定时器调用该函数:祝你好运!总结以上是DEVMAX为你收集整理的jQueryAjax请求每30秒全部内容。如果觉得DEVMAX网站内容还不错,欢迎将DEVMAX网站推荐给好友。

  10. jquery – keypress事件在IE和Chrome中不工作,但在FF工作

    任何想法为什么会这样发生?我通常认为Chrome会更加宽容代码?这是我的按键键.我错过了什么吗?右图();和leftimage();是应该工作的功能,因为我在其他地方使用这些功能谢谢您的帮助!

返回
顶部