- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道有很多关于此的问题,但似乎没有一个答案对我有用。我正在尝试编写一些 jquery 来让我的 Bootstrap 导航栏在有人滚动传递元素后改变颜色。有人可以告诉我我做错了什么。谢谢!
Github 链接:https://github.com/Sruthik22/Sruthik22.github.io jquery 在头部
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset="utf-8">
<title>Sruthi Kurada</title>
<meta name="description" content="Sruthi Kurada's Personal Website">
<meta name="author" content="Sruthi Kurada">
<!-- CSS Stylesheets -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="style.css">
<script type="text/javascript">
$(document).ready(function(){
var scroll_start = 0;
var startchange = $('#Home');
var offset = startchange.offset();
if (startchange.length){
$(document).scroll(function() {
scroll_start = $(this).scrollTop();
if(scroll_start > offset.top) {
$('nav.navbar-custom').css('background-color', '#f0f0f0');
} else {
$('nav.navbar-custom').css('background-color', 'transparent');
}
});
}
});
</script>
</head>
<body>
<nav class="navbar navbar-fixed-top navbar-custom">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#Home">Sruthi Kurada</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<div class="nav navbar-nav navbar-right">
<a class="navbar-brand nav-elements page-scroll" href="#Home">Home</a>
<a class="navbar-brand nav-elements page-scroll" href="#About">About</a>
<a class="navbar-brand nav-elements page-scroll" href="#Skills">Skills</a>
<a class="navbar-brand nav-elements page-scroll" href="#Portfolio">Portfolio</a>
<a class="navbar-brand nav-elements page-scroll" href="#Contact">Contact</a>
</div>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
<a name = "Home" id = "Home"></a>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="Images/Robotics.jpg" alt="FLL Robotics Robot">
<div class="carousel-caption">
<h1>Innovator</h1>
</div>
</div>
<div class="item">
<img src="Images/Math.jpg" alt="Math on a chalkboard">
<div class="carousel-caption">
<h1>Math Enthusiast</h1>
</div>
</div>
<div class="item">
<img src="Images/PythonCode.png" alt="Python Code on Computer">
<div class="carousel-caption">
<h1>Coder</h1>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<!--About Me-->
<a name="About" id = "About"></a>
<div class = "About">
<div class="container">
<br>
<div id="sruthi-picture"></div>
<div class="row">
<div class = "col-md-1 col-xs-1"></div>
<div class="col-md-10 col-xs-10 text-center" id="Intro">
My name is Sruthi Kurada
</div>
<div class = "col-xs-1"></div>
</div>
<div class="row">
<div class = "col-xs-1"></div>
<div class="col-xs-10 text-center" id = "Subtitle">
I am a 7th Grader at the Advanced Math & Science Academy (AMSA).
</div>
</div>
<br>
<div class="row">
<div class = "col-xs-1"></div>
<div class="col-xs-10 text-center" id = "about-descript">
I am interested in Robotics, Math, and Coding. I participate in FLL a Lego Robotics Competition. I do many mathamatics competitions, and I have coded several Python and Java Projects.
</div>
</div>
<div class="row">
<div class = "col-xs-1"></div>
<div class="col-xs-10 text-center" id = "about-descript">
I enjoy designing technology for less fortunate people and recently designed a belt to help the blind. I also play basketball & do karate as extracuriculars.
</div>
</div>
<br>
</div>
</div>
<div class = "AMSA">
<div class="row">
<div class = "col-xs-1"></div>
<div class="col-xs-10 text-center vcenter" id = "amsaText">
<p>My school the Advanced Math and Science Academy is where I participate in many activities with my friends.</p>
</div>
</div>
</div>
<a name="Skills"></a>
<div class="container">
<div class="row text-center">
<div class="col-lg-10 col-lg-offset-1">
<h2 id = "SkillsTitle">Skills</h2>
<div class="row">
<div class="col-md-3 col-sm-6">
<div class="service-item">
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-users fa-stack-1x text-primary portfolioIcon" aria-hidden="true"></i>
</span>
<h4>
<strong class = "PortfolioTextTitle">Leadership</strong>
</h4>
<br>
<p class = "PortfolioText"> Taught people on my FLL team how to build robots. Also have taught kids how to code</p>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="service-item">
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-android fa-stack-1x text-primary portfolioIcon" aria-hidden="true"></i>
</span>
<h4>
<strong class = "PortfolioTextTitle">App Developement</strong>
</h4>
<br>
<p class = "PortfolioText"> Learning Android Development and currently working on Udacity Nanodegree </p>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="service-item">
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-code fa-stack-1x text-primary portfolioIcon" aria-hidden="true"></i>
</span>
<h4>
<strong class = "PortfolioTextTitle">Python</strong>
</h4>
<br>
<p class = "PortfolioText"> Well versed in Python Application Development as well as Django Framework. </p>
</div>
</div>
<div class="col-md-3 col-sm-6">
<div class="service-item">
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-code fa-stack-1x text-primary portfolioIcon" aria-hidden="true"></i>
</span>
<h4>
<strong class = "PortfolioTextTitle">Java</strong>
</h4>
<br>
<p class = "PortfolioText"> Proficent in Java Developement. Currently learning Machine Learning.</p>
</div>
</div>
</div>
<br>
</div>
</div>
</div>
<a name="Portfolio"></a>
<div class = "Portfolio">
<div class="row">
<div class = "col-md-1 col-xs-1"></div>
<div class="col-md-10 col-xs-10 text-center" id="PortfolioTitle">
Portfolio
</div>
<div class = "col-xs-1"></div>
</div>
<div class = "row">
<div class = "col-md-2 col-sm-0"></div>
<div class="col-md-4 col-sm-6">
<div class = "portfolio-box">
<a title = "Movie App Github Source Code" href = "https://github.com/Sruthik22/MoviesApp">
<img class = "img-portfolio img-responsive" src = "Images/PopularMovies.PNG"/>
<p class = "imagetext">Movies App</p>
<div class = "portfolio-box-caption">
<div class = "portfolio-box-caption-content">
<div class = "project-category text-faded">
Android Development
</div>
<div class = "project-name">
An Android app I created that lets users find most popular movies and the top rated movies. Once you click on a movie specific movie poster then it will give you more specific details such as movie title and release date.
</div>
</div>
</div>
</a>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class = "portfolio-box">
<a title = "Clash of the Math Titans Github Source Code" href = "https://github.com/Sruthik22/Clash-of-the-Math-Titans">
<img class = "img-portfolio img-responsive" src = "Images/ClashOfTheMathTitans.png" alt="Code of Clash of the Math Titans"/>
<p class = "imagetext">Clash of the Math Titans</p>
<div class = "portfolio-box-caption">
<div class = "portfolio-box-caption-content">
<div class = "project-category text-faded">
Code
</div>
<div class = "project-name">
At a Hackathon my teammate and I designed this python game that helps young children learn the Order of Operations by gamifying it.
</div>
</div>
</div>
</a>
</div>
</div>
<div class = "col-md-2 col-sm-0"></div>
</div>
<br>
<div class = "row">
<div class = "col-md-2 col-sm-0"></div>
<div class="col-md-4 col-sm-6">
<div class = "portfolio-box">
<a title = "Battleship Github Source Code" href = "#">
<img class = "img-portfolio img-responsive" src = "Images/Battleship.png" alt="The Battleship code"/>
<p class = "imagetext">Battleship</p>
<div class = "portfolio-box-caption">
<div class = "portfolio-box-caption-content">
<div class = "project-category text-faded">
Code
</div>
<div class = "project-name">
The game battleship coded in python. There is both a single player mode and a multiplayer mode. The game also has graphics with the help of the graphics module graphics.py
</div>
</div>
</div>
</a>
</div>
</div>
<div class="col-md-4 col-sm-6">
<div class = "portfolio-box">
<a title = "Movie App Github Source Code" href = "https://www.youtube.com/watch?v=ogvRFzNWM2w">
<img class = "img-portfolio img-responsive" src = "Images/BeltForTheBlind.PNG" alt="Picture of the Limits of what a Product like the Blind Belt could do"/>
<p class = "imagetext">Belt for the Blind</p>
<div class = "portfolio-box-caption">
<div class = "portfolio-box-caption-content">
<div class = "project-category text-faded">
Hardware
</div>
<div class = "project-name">
A product I designed along with another team mate that helps the blind traverse their surroundings. It guides the user by using a ultrasonic sensor and alerts the user by using a volume component on the side of the bot. We won 3rd place in ProjectCSGirls.
</div>
</div>
</div>
</a>
</div>
</div>
<div class = "col-md-2 col-sm-0"></div>
</div>
<br>
</div>
<a name="Contact"></a>
<div class = "Contact">
<div class="row">
<div class = "col-md-1 col-xs-1"></div>
<div class="col-md-10 col-xs-10 text-center">
<h1 id="ContactTitle">Contact</h1>
</div>
<div class = "col-xs-1"></div>
</div>
<div class = "row">
<div class = "col-md-4 col-sm-4"></div>
<div class = "col-md-1 col-sm-1">
<a target="_blank" href = "https://github.com/Sruthik22" class = "social"><i class="fa fa-github-square social"></i></a>
</div>
<div class="col-md-2 center col-sm-2">
<a target="_blank" href = "mailto:fllheroes638@gmail.com" class = "social"><i class="fa fa-envelope icon social"></i></a>
</div>
<div class = "col-md-1 col-sm-1">
<a target="_blank" href = "http://stackoverflow.com/users/5693112/sruthi-kurada" class = "social"><i class="fa fa-stack-overflow social"></i></a>
</div>
<div class = "col-md-4 col-sm-4"></div>
</div>
</div>
</body>
</html>
最佳答案
您只是将 background-color
应用于错误的元素。试试这个:
$(document).scroll(function() {
scroll_start = $(this).scrollTop();
if(scroll_start > offset.top) {
$('nav.navbar-custom').css('background-color', '#f0f0f0');
} else {
$('nav.navbar-custom').css('background-color', 'transparent');
}
});
关于jquery - 更改滚动条上 Bootstrap 导航栏的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38647415/
在带有 jQuery 的 CoffeeScript 中,以下语句有什么区别吗? jQuery ($) -> jQuery -> $ - > 最佳答案 第一个与其他两个不同,就像在纯 JavaScr
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭13 年前。 Improve th
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
这个问题可能听起来很愚蠢,但请耐心等待,因为我完全是初学者。我下载了两个 jQuery 版本,开发版本和生产版本。我想知道作为学习 jQuery 的初学者,什么更适合我。 最佳答案 如果您对 jQue
The documentation说要使用 1.6.4,但我们现在已经升级到 1.7.2。 我可以在 jQuery Mobile 中使用最新版本的 jQuery 吗? 最佳答案 您当然可以,但如果您想
我在这里看到这个不错的 jquery 插件:prettyphoto jquery lightbox有没有办法只用一个简单的jquery来实现这样的效果。 我只需要弹出和内联内容。你的回复有很大帮助。
很明显我正在尝试做一些 jQuery 不喜欢的事情。 我正在使用 javascript 上传图片。每次上传图片时,我都希望它可见,并附加一个有效的删除脚本。显示工作正常,删除则不然,因为当我用 fir
这两个哪个是正确的? jQuery('someclass').click(function() { alert("I've been clicked!"); }); 或 jQuery('somec
我正在寻找一个具有以下格式的插件 if (jQuery)(function ($) { -- plugin code -- })(jQuery); 我明白 (function ($)
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭10 年前。 Improv
我知道这个问题已经被问过几次了,但想知道您是否可以帮助我解决这个问题。 背景:我尝试创建一个使用 Ajax 提交的表单(jQuery 表单提交)。我已经工作得很好,然后我想在表单上得到验证。我可以使用
我正在使用无处不在的jquery validate plugin用于表单验证。它支持使用metadata plugin用于向表单元素添加验证规则。 我正在使用此功能。当验证查找这些规则时,它会对元素进
我更喜欢为我一直在开发的网络社区添加实用的视觉效果,但随着事情开始堆积,我担心加载时间。 拥有用户真的更快吗加载(希望是缓存的)副本来自 Google 存储库的 jquery? 是否使用 jQuery
这个问题已经有答案了: Slide right to left? (17 个回答) 已关闭 9 年前。 你能告诉我有没有办法在 jQuery 中左右滑动而不使用 jQuery UI 和 jQuery
我如何找出最适合某种情况的方法?任何人都可以提供一些示例来了解功能和性能方面的差异吗? 最佳答案 XMLHttpRequest 是原始浏览器对象,jQuery 将其包装成一种更有用和简化的形式以及跨浏
运行时 php bin/console oro:assets:build ,我有 11 个这样的错误: ERROR in ../node_modules/jquery-form/src/jquery.
我试图找到 jQuery.ajax() 在源代码中的定义位置。但是,使用 grep 似乎不起作用。 在哪里? 谢谢。 > grep jQuery.ajax src/* src/ajax.js:// B
$.fn.sortByDepth = function() { var ar = []; var result = $([]); $(this).each(function()
我的页面上有多个图像。为了检测损坏的图像,我使用了在 SO 上找到的这个。 $('.imgRot').one('error',function(){ $(this).attr('src','b
我在理解 $ 符号作为 jQuery 函数的别名时遇到了一些麻烦,尤其是在插件中。你能解释一下 jQuery 如何实现这种别名:它如何定义 '$' 作为 jQuery 函数的别名?这是第一个问题。 其
我是一名优秀的程序员,十分优秀!