- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我修改了这个jsFiddle http://jsfiddle.net/tV9z9/23/像这样工作 jsFiddle http://jsfiddle.net/warmwhisky/N68wX/13/
当脚本第一次运行时,我称之为级别 1。然后单击其中一个缩略图并移动到级别 2。我想通过单击返回运行状态(级别 1)。也许是关闭按钮或返回到首次运行状态?
我试过在 js 中使用 onclick,但我无法让它工作。
我应该使用 onlick 还是可以保存 jquery 的状态并返回它?
这是代码
JS...
$(function() {
var content = $('#content'),
services_level2 = $('#services_level2'),
contentHeight = content.height(),
contentWidth = content.width(),
level2Width = services_level2.width(),
nav = $('#nav'),
count = 0;
// on load content height is shorter
content.width(0);
services_level2.width(613);
nav.find('a').on('click', function() {
var $this = $(this),
parent = $this.parent(),
targetElement = $this.attr('href');
//Does the slide animation once
if (count === 0) {
//Slide out and fade away the main copy
services_level2.animate({'width': services_level2 }, function() {
$(services_level2).animate({
'margin-left': '300%',
opacity: 0
}, 900);
});
content.animate({'width': contentWidth }, function() {
parent.addClass('active');
//animate in
$(targetElement).animate({
left: '-=210px',
'margin-left': '30%',
opacity: 1
}, 400);
});
count = 1;
} else {
//only add active class if parent does not have it and then animate it
if ( !parent.hasClass('active') ) {
parent.addClass('active');
//animate in
$(targetElement).animate({
left: '-=210px',
'margin-left': '30%',
opacity: 1
}, 500);
//Gets older clicked element
var oldClickedElement = $('.active').not(parent).removeClass('active').find('a').attr('href');
//only if old click element exists the do the animation
if (oldClickedElement) {
//animate out + reset to start
$(oldClickedElement).animate({
left: 0,
'margin-left': '-50%',
opacity: 0
}, 500, function() {
$(oldClickedElement).css({
'margin-left' : '100%',
left: 0
});
});
}
}
}
return false;
});
});
HTML...
<div id="container">
<div id="services_level2">
<h1>IT Services</h1>
<p>Lorem ipsum dolor sit amet, et mel falli simul platonem, cu consul utroque neglegentur duo. Omnis soluta periculis eu sit.
</p>
<h1>Repairs</h1>
<p>
Sit te habeo neglegentur, nam no dicit intellegat. Epicuri blandit sea eu, eum nibh adhuc mundi eu.
</p>
<h1>Other</h1>
<p>
Pri nihil scaevola salutatus id, esse minimum vis ne. Verear corrumpit vim ex, vim tollit scaevola ea.
</p>
</div>
<div id="content">
<!--<div id="zero"><p>Zero</p></div>-->
<div id="one"><h1>Objective</h1><p>Lorem ipsum dolor sit amet, et mel falli simul platonem, cu consul utroque neglegentur duo.</p><h1>Delivery</h1><p>Sit te habeo neglegentur, nam no dicit intellegat. </p><h1>Performance</h1><p>Pri nihil scaevola salutatus id, esse minimum vis ne. Verear corrumpit vim ex, vim tollit scaevola ea, est id suas delectus deseruisse.</p></div>
<div id="two"><p>Two</p></div>
<div id="three"><p>Three</p></div>
<div id="four"><p>Four</p></div>
<div id="five"><p>Five</p></div>
<div id="six"><p>Six</p></div>
</div>
<ul id="nav">
<!--<li><a href="#zero"><img src="http://dev3.stellaworld.co.uk/public_html/development/ssl/website/level3/itservices/images/0.jpg"></a>
</li>-->
<li><a href="#one"><img src="http://dev3.stellaworld.co.uk/public_html/development/ssl/website/level3/itservices/images/1.jpg"></a>
</li>
<li><a href="#two"><img src="http://dev3.stellaworld.co.uk/public_html/development/ssl/website/level3/itservices/images/2.jpg"></a>
</li>
<li><a href="#three"><img src="http://dev3.stellaworld.co.uk/public_html/development/ssl/website/level3/itservices/images/3.jpg"></a>
</li>
<li><a href="#four"><img src="http://dev3.stellaworld.co.uk/public_html/development/ssl/website/level3/itservices/images/4.jpg"></a>
</li>
<li><a href="#five"><img src="http://dev3.stellaworld.co.uk/public_html/development/ssl/website/level3/itservices/images/5.jpg"></a>
</li>
<li><a href="#six"><img src="http://dev3.stellaworld.co.uk/public_html/development/ssl/website/level3/itservices/images/6.jpg"></a>
</li>
</ul>
</div>
CSS...
#container {
height:390px;
overflow:hidden;
float:left;
background: #ccc no-repeat;
min-width:918px;
padding: 10px 10px 10px 10px;
}
#services_level2 {
position:fixed;
background:white;
padding:20px;
height: 345px;
}
#content {
width: 650px;
height: 385px;
position: relative;
overflow: hidden;
float: right;
}
#content > div {
display:block;
width:600px;
height:385px;
background:white;
position:absolute;
margin-left:100%;
/*left:-200px;*/
opacity: 0;
padding:10px 20px 0 40px;
}
#nav {
list-style: none;
display: table;
margin: 0px 0 0 0;
position: relative;
width: 260px;
float:right;
}
#nav li {
/* width: 100px; */
/* height: 100px; */
float: left;
margin-right:5px;
/*border: 1px solid black;*/
}
#nav a {
color:#fff;
text-decoration:none;
width:100%;
height:100%;
}
ul {
padding:0;
}
li.active {
opacity:0.4;
filter:alpha(opacity=40);
}
最佳答案
您需要梳理您的代码并列出第一次单击时更改的所有值,然后在单击 #reset 时反转每个值。 -=200px 会变成 +=200px 等等。
关于javascript - jQuery - 2 级 slider 通过单击返回到 1 级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23202991/
我最后一次使用C++是在它无法被管理之前。不过最近,我从 Java 回来,看到现在可以管理 C++ 了! 没过多久我就意识到gcnew 和^ 的用途。但是,我对容器有点卡住了。 如何创建一个容器,其元
我离开 Microsoft 堆栈已有一段时间了,专注于 Linux、开源内容和 PHP 中的 Web 开发。我曾经在 Dev Studio(所有 C 和 C++)中在 Windows 上进行一些桌面应
在我的程序中有两个 View Controller 。第一个有表格 View 。当我单击一个单元格时,相关的炎症会显示在第二个 View Controller 中。它运作良好。 当我返回到第一个 Vi
我使用 AVAssetWriter 和 CMSampleBuffer 数据(来自视频、音频输入)录制视频(.mp4 文件)。 在录制时我想处理帧,我正在将 CMSampleBuffer 转换为 CII
在 python 中有两种不同的离开循环的选项。 continue 将您带回到循环的开头,break 就像一个电灯开关,它会在脚本运行的剩余时间内切断循环。我的问题是我有一个 while True 循
我是 Git 的新手,我正试图恢复到 SourceTree 中的先前提交。我右键单击要还原到的提交,然后单击 checkout 。它给了我一个提示,说我的工作副本将成为一个独立的头。这是什么意思,这是
所以我决定在离开几年后,为了我的一些个人项目重新使用 Ruby on Rails。我想知道的是,找出 Rails 中的新功能的最佳资源是什么?自从 1.2 是新的以来,我什至没有真正接触过 Rails
我的项目有两个部分。第一部分是在 Storyboard中制作的,第二部分是 SKView。如何从 SKView 中的第二部分返回到主 UIView? 最佳答案 创建自定义 ViewController
所以我在大约四次提交前对我的项目做了一个糟糕的改变。我了解到我可以恢复到之前描述的状态 here ,并通过依次检查以前的提交(并在我的设备上测试它们),我已经确定了问题发生的位置。 现在我想回到坏改变
我想知道,在 Canvas 的 commandAction 方法中,如何让我的命令按钮回到 MIDlet 的开始? (基本上重新开始)。 当按键触发时,我将它带到一个新的列表页面。在该页面上,我有一个
我想知道是否可以使用 intro.js 返回到下一行。我尝试了\n 和其他类似的东西,但它们中的任何一个都有效并且不可能在文档中找到类似的东西。有谁知道这是否可能? 最佳答案 正确的做法是像这样使用
这是关于我发现我的应用程序面临的一个反复出现的问题,它与使用几个 DialogFragment 相关。我主要针对平台级别 8 设备,因此要使用 DialogFragments,我必须使用兼容性库。 每
我有一个 uiview 的问题,它放置在 Storyboard的一个位置,在应用程序启动后,我将 uiview 移动到第二个位置,并使用代码中的按钮进行动画处理。 int alpha = -212;
我有 Controller B,它使用委托(delegate)模式将数据发送回 Controller A,但由于某种原因我的 segue 没有触发。 是否有什么东西阻止我的 segue 被触发?我将如
我已经找到了处理除我需要的之外的所有内容的解决方案。这是场景 就像在 GMail 中一样 - 主要内容呈现在 iframe 中。单击主页上的链接会指向 iframe。这效果很好,而且无缝。此时,如果我
我有一个 RCP 程序,带有需要登录的启动屏幕。 我想制作一个注销按钮。通过单击此按钮,用户应该返回到初始屏幕,因此他必须重新登录.. 这可能吗? 提前致谢。 最佳答案 如果您使用org.eclips
我有一个数据框: df = pd.DataFrame({'Section': [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6],
是否可以将元素 $("p") 返回到应用 mouseenter() 方法之前的确切颜色?或者我是否需要知道 mouseenter() 之前的颜色,然后使用 mouseleave() 应用该颜色?我希望
在 Matlab R2016b 中,显示某些数据类型的变量会显示有关该类型的信息。当通过不带最终分号键入变量来显示变量时会发生这种情况(使用 disp 函数时不会发生这种情况)。 比较例如: Matl
是否可以告诉 RSpec::Mocks 为一组值 stub 一个方法,否则回退到原始方法?例如: File.stub(:exist?).with(/txt/).and_return(true) Fil
我是一名优秀的程序员,十分优秀!