- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在图像悬停时显示文本。它适用于 div 悬停,但我只希望在图像悬停时使用它,而这似乎并没有发生。以下是我的代码片段..
$(document).ready(function(){
$(".navbar-links").click(function(){
//alert("hi1");
$(".navbar-links").removeClass("active");
$(this).addClass("active");
});
var portfolio_offset = $("#portfolio-section").offset().top;
var about_offset = $("#about-section").offset().top;
var contact_offset = $("#contact-section").offset().top;
$(window).scroll(function(){
//alert(about_offset);
//alert(portfolio_offset);
//alert(contact_offset);
$(".navbar-links").removeClass("active");
var scrolled_offset = $(this).scrollTop();
if(scrolled_offset>=contact_offset-1)
{
$("#contact_link").addClass("active");
}
else if(scrolled_offset>=portfolio_offset)
{
//alert(scrolled_offset);
$("#portfolio_link").addClass("active");
//$("#contact_link").removeClass("active");
}
else
{
$("#about_link").addClass("active");
//$("#contact_link").removeClass("active");
}
});
$("button").click(function(){
window.open($(this).val(),"_blank");
});
});
button {
background : transparent;
border : 1px solid white;
padding : 0px;
margin : 10px;
}
i {
border : 0px;
}
#about-section {
background-color : #fd746c;
color : black;
}
#portfolio-section {
background-color : #904e95;
color : black;
}
#contact-section {
background-color : #4ca1af;
color : black;
}
.active {
border : 1px solid white;
}
#navbar-menu {
text-align : center;
}
.heading {
font-family : Sofia;
}
.navbar {
background-color : black;
}
.content {
font-family : Lily Script One;
}
.navbar-brand {
font-size : 27px;
}
.content-div {
text-align : center;
display : inline-block;
vertical-align : middle;
float : none;
}
.navbar-links {
font-size : 20px;
}
.center {
text-align : center;
}
img {
border : 1px solid black;
margin : auto;
top : 0;
left : 0;
right : 0;
bottom : 0;
box-shadow : 10px 10px 20px black;
}
.project-img {
max-width : 70%;
max-height : 70%;
}
.fa {
padding : 20px;
font-size : 45px;
width : 100px;
text-align : center;
text-decoration : none;
background : #2c4762;
color: white;
margin : 0px 0px;
border : 1px solid white;
}
.fa:hover {
opacity : 0.7;
}
#proj_img_1{
position : relative;
text-align : center;
}
#img_desc {
position : absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background : grey;
color : black;
visibility : hidden;
opacity : 0;
transition : opacity .5s, visibility .5s;
}
#proj_img_1:hover #img_desc {
visibility : visible;
opacity : 1;
}
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="row" id="navbar-section">
<div class="col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10">
<div class="navbar-header heading">
<button class="navbar-toggle" data-toggle="collapse" data-target="#navbar-menu"><span class="glyphicon glyphicon-triangle-bottom"></span></button>
<a href="#" class="navbar-brand">Portfolio Page</a>
</div>
<div id="navbar-menu" class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right heading">
<li class="navbar-links active" id="about_link"><a href="#about-section">About</a><li>
<li class="navbar-links" id="portfolio_link"><a href="#portfolio-section">Portfolio</a><li>
<li class="navbar-links" id="contact_link"><a href="#contact-section">Contact</a><li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<div class="container-fluid" id="scrollable-div">
<div class="row" id="about-section">
<br>
<br>
<div class="center heading">
<h1>About</h1>
</div>
<div class="col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-offset-1 col-xs-10">
<div class="row">
<div class="col-md-offset-1 col-md-6 col-sm-offset-1 col-sm-6 col-xs-offset-1 col-xs-10 content-div content">
<h3>Rishabh Kashyap</h3>
<h3>Full Stack Web Developer</h3>
<h3>Key Interests - JavaScript & MEAN Stack</h3>
<h3>Worked as an intern @ Sapient Global Markets</h3>
<h4><i>"Never be afraid to take risks. If you succeed, you can lead and if you fail, you can guide."</i><h4>
<h4>- Swami Vivekananda</h4>
<h3>Indeed. The motto, I try to live by. Professionally, as well as, Personally.</h3>
</div>
<div class="col-md-4 col-sm-4 col-xs-12 content-div">
<img class="img-responsive project-img" alt="my image" src="https://lh3.googleusercontent.com/34CJNU0DexpintEhsM5-zcZdT_7mRWVA6dE-7f122WM3xj4xFI0nXYQhXyEG8tyrd4piHPHPGtCNtu_o5vqZ2eFFH2W9YS4ekKCqw7wgZzAjsKD8hdNoV5DrARz7I-BRljjksmdfHxoHaGIgwxcNYRJkEBa2FLIhbluVGZo1qN3zZ1ZJ1WpRU27mBbrCScNzazuOFtY0lOBX4JAKd7yGlC7ILwg4gAy-KsN-ZJz54PoNeCblgrz3jGsF8YvEf5Hc-V3kV8DtrDiKiwTpXPowvrLdldS-rIlOpjq1LrbPVNxWUNB1YieiqOUo1AEVYaS9WxiIFae2etL7Jb4nAW9MkLHE-YvQZ4VVcntRfXS3CBnuoy6EPHu2vfevnNeK9lgANs4rb1MNyMCxOACWmn45_vZKZoPfnmk_cyVzt7m2vFZUXPMdyeSRrViQD9VteriL89XHZlItrlgIhXI1vt5JAASHdOYrNV3CTpWMGPfzQk0BfQbbr2qcxnbgbSyEmK4M1wIloFQ0O_q-MCOdffySKCmct8iHRRrAcG5cWF_ArcX5GptL3tHAQHu9UCyfrjwIyI28NbrgZM0NkxxmpRAV5nRJGQetgxewxGaS2A6xfWnlW8jP-P4z=w479-h638-no?.jpg"/>
</div>
</div>
</div>
</div>
<div class="row" id="portfolio-section">
<br>
<br>
<div class="center heading">
<h1>Portfolio</h1>
</div>
<div id="proj_img_div" class="col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-offset-1 col-xs-10">
<img id="proj_img_1" class="img-responsive project-img" alt="portfolio page" src="http://www.thefamouspeople.com/profiles/images/swami-vivekananda-3.jpg"/>
<h4 id="img_desc"><i>A tribute page to Swami Vivekananda using basic HTML & Bootstrap.</i></h4>
</div>
</div>
<div class="row" id="contact-section">
<br>
<br>
<div class="center heading">
<h1>Contact Me</h1>
</div>
<div class="col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-offset-1 col-xs-10">
<div class="center content">
<h4><i>rishabhkashyap.rk@gmail.com</i></h4>
</div>
<br>
<div class="center">
<button value="https://www.facebook.com/rishabh.kashyap.940436"><i class="fa fa-facebook"></i></button>
<button value="https://twitter.com/iamrkcheers"><i class="fa fa-twitter"></i></button>
<button value="https://github.com/iamrkcheers"><i class="fa fa-github"></i></button>
<button value="https://www.freecodecamp.com/iamrkcheers"><i class="fa fa-free-code-camp"></i></button>
<button value="https://www.linkedin.com/in/rishabh-kashyap-735879117/"><i class="fa fa-linkedin"></i></button>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
</div>
</div>
<div class="row" id="meta-section">
<div class="col-md-offset-1 col-md-10 col-sm-offset-1 col-sm-10 col-xs-offset-1 col-xs-10">
</div>
</div>
</div>
以下是我的工作代码.. https://codepen.io/iamrkcheers/pen/KmxEpw
感谢任何帮助。谢谢。
此外,我希望文本仅显示在图像的顶部,而它出现在整个 div 的顶部。如何实现?
谢谢。
最佳答案
你的 CSS #proj_img_1:hover #img_desc
中的这个选择器说“当我将鼠标悬停在 #proj_img_1
上时,应用一些东西到我的 child #img_desc
”。
但是,#img_desc
是#proj_img_1
的 sibling ,而不是 child 。
改用#proj_img_1:hover + #img_desc
。
+
用于相邻的 sibling ,所以它说“当我将鼠标悬停在 #proj_img_1
上时,应用一些东西到我的下一个 sibling #img_desc
".
关于html - 在 img 悬停时显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44204613/
我正在学习和使用 jQuery,并且想要显示某些元素的删除图标。 我有一个外部主 div,其中包含许多元素的包装器。在元素包装器内部,我想当用户将鼠标悬停在元素包装器上时显示删除图标,并在用户移出元素
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我从 Qt 开始,每当有人将鼠标悬停在 QPushButton 上时,我想将 QPushButton 设置为不同的图标。到目前为止,这是我的代码: #include QPushButton *but
我从 Qt 开始,我想在有人将鼠标悬停在 QPushButton 上时将其设置为不同的图标。到目前为止,这是我的代码: #include QPushButton *button = new QPus
我有以下代码... jQuery(function($) { var timer; $('.action-viewer').hide(); $('.task').on('mouseover
我有一张照片,当用户将鼠标悬停在它上面时,我会在照片顶部显示(使用绝对定位)2 个箭头,一个用于进入上一张照片,一个用于进入下一张照片。这是到目前为止的代码... $('a.large_product
$('li > a').hover( function(){ $(this).animate({ backgroundColor: '#2a639a', color: '#fff'
我有一个悬停事件附加到几个链接,当您点击它时,会出现一个框。 有没有一种方法可以让悬停事件仅在鼠标悬停在链接上超过 500 毫秒时触发?因此,目前只要鼠标移到链接上,就会出现该框,但我希望只有当鼠标悬
我正在创建包含各种样式控件的演示应用程序。它允许我快速预览更改。 我的问题是下面的代码不起作用: Pressed button 它表示 IsPressed 的 setter 受到保护。我明白了,但我需
我正在尝试使用 js 并创建带有一些“信息文本”的“描述框” HTML google JS function info() {} 我不知道是哪个代码用一些文本创建了所谓的“描
我有一个 Accordion 风格的菜单,在悬停状态下工作正常,但我想改为点击... $(document).ready(function(){ $('#nav > li').hover(
我正在使用 Chartjs v.1.0.2 并尝试将点设置为仅在悬停在当前点上时出现。同样的问题是当我使用悬停或鼠标悬停时。可以使用 getPointsAtEvent(e); 找到当前点,但它仅在我将
我使用foreach 语句访问IEnumerable 的所有元素并将其呈现在详细信息页面中。我想让每个元素的悬停属性只影响一个元素。所以我使用 jQuery 单独影响每个元素 但是当我运行代码并将鼠标
首先提前感谢您的帮助。 案例:我在一行中有多个 div。这些 div 位于一个框中,我可以在此框中水平滚动以查看其他 div。我制作了两个按钮(L 表示左侧,R 表示右侧),以便在悬停或单击这些按钮时
我正在创建一个应用外观页面。 我希望在鼠标悬停时打开底部菜单上的其中一个按钮。 这感觉像是一项简单的任务,但我所做的一切似乎都不起作用。我错过了什么,我做了很多研究,但似乎找不到解决方案。 我尝试使用
我遇到的问题是,当您将鼠标悬停在按钮上时,只有按钮的某些部分会触发悬停/可点击状态,而不是所有实际 block 。有什么想法吗? 这是使用它的站点:http://www.revival.tv/turn
我有一位客户想要在他们的网站上实现特定功能,但我有点困惑如何做到这一点。 基本上,如果你查看他们的 existing site您可以看到 4 个圆形按钮。 他们想要的是,当有人将鼠标悬停(或单击,如果
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 9 年前。 关于您编写的代码问题的问题必须在问题本身中描述具体问题 — 并且包括有效代码 以
我目前正在编写我的第一个响应式网站(总的来说我是一个初学者)并且我遇到了很多障碍。其中之一是我的菜单有问题。我会尽量具体。我有一个用于桌面的水平菜单和一个用于平板电脑/手机的垂直菜单。我不知道如何解决
我正在为网站创建菜单。我正试图在链接上实现悬停 和点击 效果。我希望列表元素 a 上的悬停事件触发彩色动画并添加“事件”类。如果触发了点击和悬停事件,我想为该元素分配相同的类。问题是,一旦元素未悬停并
我是一名优秀的程序员,十分优秀!