- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 javascript 新手,遇到了一些麻烦。我正在尝试创建一个脚本,当单击小图片时,div 会滑动打开并提供图片中人物的简介。一行有 5 张图片,文本 div 位于每行的底部。
我试图确保如果再次单击同一个图像或下一行上的图像,则 div 关闭,但如果在同一行上单击另一个图像,则保持打开状态并切换到下一个描述,没有动画。
环顾四周后,我想出了这个。
JS。
<script>
$(function () {
var tabContainers = $('div.tabs > div');
$('div.tabs ul.tabNavigation a').click(function () {
tabContainers.hide().filter(this.hash).slideToggle("slow");
tabContainers.hide().filter(this.hash).show();
$('div.tabs ul.tabNavigation a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
</script>
CSS。
<style type="text/css">
UL.tabNavigation {
list-style: none;
margin: 0;
padding: 0;
}
UL.tabNavigation LI {
display: inline;
}
UL.tabNavigation LI A {
border-left: 35px solid transparent;
border-right: 35px solid transparent;
}
A.selected {
border-left: 35px solid transparent;
border-right: 35px solid transparent;
border-bottom: 35px solid gray;
}
UL.tabNavigation LI A:focus {
outline: 0;
}
div.tabs > div {
padding: 5px;
margin-top: 3px;
border: 0 px solid #333;
}
div.tabs > div h2 {
margin-top: 0;
}
HTML。
<div class="container">
<div class="tabs">
<ul class="tabNavigation">
<li><a href="#alex"><img id="flip" src="{% static 'img/alex-headshot-stone.png' %}" alt="Photo of Alex Chamberlain" class="img-team img-thumbnail"/></a></li>
<li><a href="#ed"><img id="flip" src="{% static 'img/ed_snajder.jpg' %}" alt="Photo of Ed Snajder" class="img-team img-thumbnail"/></a></li>
<li><a href="#nicole"><img id="flip" src="{% static 'img/nicole-phelps.jpg' %}" alt="Photo of Nicole Phelps" class="img-team img-thumbnail"/></a></li>
</ul>
<div id="alex">
<h3>Alex Chamberlain<span id=":14h" tabindex="-1"></span></h3>
<p><b>Puppet Labs</b><br>
Software Quality Assurance Engineer</p>
<ul>
<li>Linked-in: <a href="http://www.linkedin.com/pub/alex-chamberlain/35/9a/911">Alex Chamberlain</a></li>
</ul>
<br />
<p>Alex Chamberlain has been involved in the process of software development in various capacities for almost twenty years, with a special interest in solving real-world problems by applying a thoughtful, user-centered approach to software design. He has worked as a software engineer, business systems analyst, software tester, and college teacher of computer programming. In his current position at Puppet Labs he is involved in all phases of testing Puppet Enterprise, an automated system-administration and configuration management tool, from high-level product-requirements analysis through hands-on manual testing.</p>
<p> Currently he is focused on development of automated web application testing tools. When not staring at a screen, he enjoys playing the guitar loudly and badly, cooking, taking care of his two elderly cats, and tinkering with vintage Japanese motorcycles.</p>
</div>
<div id="ed">
<h3>Ed Snajder<span id=":14h2" tabindex="-1"></span></h3>
<p><b>Jive Software</b><br>
Staff DB Engineer</p>
<ul>
<li>Linked-in: <a href="http://www.linkedin.com/in/edinor">Ed Snajder</a></li>
<li>O'Reilly Webcasts: <a href="http://www.oreilly.com/pub/au/5704">Ed Snajder</a></li>
</ul>
<p>Ed is the Database Administrator at Jive Software. He has been administering databases and analyzing data and for over 10 years, and today finds himself working with PostgreSQL, MySQL, SQL Server and Oracle relational database engines, as well as HBase, Pig and other distributed technologies. He works on query and data structure design, performance optimization, systems configuration and troubleshooting for both internal and on-premises systems. </p>
<p>When not having fun with databases, Ed is an aspiring hacker, with a self-built 3D printer, a couple of Raspberry Pis, and several mostly finished Arduino projects. An avid Portland tech community supporter, Ed has spoken at and participated in the PostgreSQL User Group, OSCON, Portland Code Camp, SQL Saturday and the Oregon SQL Developers' Group.</p>
</div>
<div id="nicole">
<h3>Nicole Phelps<span id=":14h3" tabindex="-1"></span></h3>
<p><b>Mash LLC</b><br>
Software Developer</p>
<ul>
<li>Linked-in: <a href="https://www.linkedin.com/pub/nicole-phelps/46/79a/927">Nicole Phelps</a></li>
</ul>
<br />
<p>Nicole is a software developer at Mash LLC in Portland, working on a project for Google. She wrote her first program as a sophomore at Oregon State University and, ever since, has become immersed in software development and entrepreneurship. While currently finishing her OSU degree in Computer Science with a focus on HCI, Nicole is starting the OSU App Challenge, a competition aimed at helping other students develop their technical skills and creativity. </p>
<p>She has done mobile application development for OSU, Maps Credit Union, BuyBott, and Bioniq Health. Some development tools she enjoys using the most are Native iOS, Ruby on Rails, and Titanium development. When not on the computer, Nicole is usually playing volleyball or reading sci-fi/fantasy books.</p>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-4" style="float:left"> <img src="{% static 'img/kelly.jpg' %}" alt="Photo of Kelly White" class="img-team img-thumbnail"/>
<h3>Kelly White<span id=":14h" tabindex="-1"></span></h3>
<p><b>Silvertail Software</b><br>
President</p>
<ul>
<li>Building Apps for Windows Phone: <a href="http://www.winphonedev.me/">Kelly White</a></li>
<li>Linked-in: <a href="https://www.linkedin.com/in/kellywhite">Kelly White</a></li>
</ul>
<br />
<p>Kelly White is the President of Silvertail Software, a software consultancy specializing in XAML solutions for the Windows Phone and Windows 8 App Stores. He has over 13 years of industry experience building web applications, and has a passion for startups as a serial entrepreneur. Kelly has served on the organizing boards for the Portland Code Camp, Portland Startup Weekend, and the Oregon Game Project Challenge. He also founded and previously ran the Silverlight and Windows Phone user groups in Portland, Oregon.</p>
<p> Kelly is a Microsoft MVP in Windows Phone Development, and speaks regularly at user groups, code camps, and other developer-related events throughout the Pacific Northwest on Windows Phone and Windows 8 App Development.</p>
</div>
</div>
</div>
这将匹配图像的正确文本并为我提供动画,但我不知道如何从隐藏的文本 div 开始,并且在单击下一张图像时不显示动画,或在再次单击图像时隐藏.
如果有人能指出我正确的方向,我将非常感激。
最佳答案
由于所有图像都丢失了,而且东西都在其他东西之上,所以我从头开始并按照您的指示:
我放入2行5张图像进行测试:
每个图像行都有类.people
每个图像都有类.person
每个bio行都有类.bios
每个bio都有类.bio
代码注释得很好:
$('.person').click(function() {
// Get some info
var openRow = ($('.bios:visible').index() - 1) / 2; // Open Row #
var openImage = $('.bios:visible .bio:visible').index(); // Open Image #
var currentRow = $(this).parent().index() / 2; // Clicked Row #
var currentImage = $(this).index(); // Clicked Image #
// Hide all individual bios
$('.bio').hide();
// Show only the chosen bio
$('.bios').eq(currentRow).children().eq(currentImage).show();
// Hide all bios sets
$('.bios').not(':eq(' + currentRow + ')').slideUp();
// Show only the chosen bios set
$('.bios').eq(currentRow).slideDown();
// If the same image has been clicked
if (openRow == currentRow && openImage == currentImage)
$('.bios').eq(currentRow).slideUp(); // Then hide the set});
希望这有帮助!
关于Javascript在多个图像下隐藏一个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23024449/
代码如下: http://jsfiddle.net/t2nite/KCY8g/ 我正在使用 jquery 创建这些隐藏框。 每个框都有一些文本和一个“显示”和“隐藏”按钮。我正在尝试创建一个“显示/隐
我正在尝试做某事。如果单击一个添加 #add-conferance 然后菜单将显示.add-contact。当点击隐藏然后它显示隐藏。我也将 setTimeout 设置为 7sec,但我希望当我的鼠标
我有一个多步骤(多页?)表单,只要用户按下“下一步”或“上一步”按钮,表单字段就会通过 div 显示和隐藏。 我只想禁用第一个 div (div id="page1"class="pageform")
我有一个使用 IIS 6 和 7 的当前系统,用 ASP.NET 和 .NET 4 中的 C# 编写。 My purpose is to hide the url completely (as per
我正在建立一个网站,并有一个幻灯片。幻灯片有标题和索引,覆盖整个页面。当覆盖被激活时,标题需要消失。当覆盖层被停用时,通过单击退出按钮、缩略图链接或菜单链接,字幕必须返回。 这就是我目前所拥有的
我正在尝试为显示/隐藏功能制作简单的 jquery 代码。但我仍然做错了什么。 $(document).ready(function(){ $('.arrow').click(function
我有一个自定义对话框并使用它来代替 optionMenu。所以我希望 myDialog 表现得像菜单,即在按下菜单时显示/隐藏。我尝试了很多变体,但结果相同: 因为我为 myDialog 设置了一个
在我的项目中,我通过 ViewPager 创建我的 tabBar,如下所示: MainActivity.java mViewPager = (ViewPager) findViewById(R.id.
我目前正在使用一个 Excel 表,我将第 1-17 行分组并在单元格 B18 中写入了一个单元格值。我想知道当我在展开/折叠行时单击 +/- 符号时是否有办法更改 B18 中的值。 例如:我希望 B
我想创建一个按钮来使用 VBA 隐藏和取消隐藏特定组。我拥有的代码将隐藏或取消隐藏指定级别中的所有组: Sub Macro1() ActiveSheet.Outline.ShowLevels RowL
我是 VBA 新手。我想隐藏从任何行到工作表末尾的所有行。 我遇到的问题是我不知道如何编程以隐藏最后写入的行。 我使用下一个函数知道最后写入的单元格,但我不知道在哪里放置隐藏函数。 last = Ra
我想根据另一个字段的条件在 UI 上隐藏或更新一个字段。 例如,如果我有一个名为 Color 的字段: [PXUIField(DisplayName="Color")] [PXStringList("
这是我尝试开始收集通常不会遇到的 GCC 特殊功能。这是@jlebedev 在另一个问题中提到g++的“有效C++”选项之后, -Weffc++ This option warns about C++
我开发了一个 Flutter 应用程序,我使用了 ProgressDialog小部件 ( progress_dialog: ^1.2.0 )。首先,我展示了 ProgressDialog小部件和一些代
我需要在 API 17+ 的同一个 Activity(Fragment) 中显示/隐藏状态栏。假设一个按钮将隐藏它,另一个按钮将显示它: 节目: getActivity().getWindow().s
是否可以通过组件的 ts 代码以编程方式控制下拉列表的显示/隐藏(使用 Angular2 清楚)- https://vmware.github.io/clarity/documentation/dro
我想根据 if 函数的结果隐藏/显示 NiceScroll。 在我的html中有三个部分,从左到右逐一滚动。 我的脚本如下: var section2 = $('#section2').offset(
我有这个 jquery 代码: $(document).ready(function(){ //global vars var searchBoxes = $(".box"); var searchB
这个问题已经有答案了: Does something like jQuery.toggle(boolean) exist? (5 个回答) 已关闭 6 年前。 在 jQuery 中(我当前使用的是 1
我在这样的选择标签上使用 jQuery 的 selectMenu。 $('#ddlReport').selectmenu() 在某些情况下我想隐藏它,但我不知道如何隐藏。 这不起作用: $('#ddl
我是一名优秀的程序员,十分优秀!