我有一些社交媒体图标,我想在它们徘徊时改变颜色.我认为最简单的方法是用新的替换图像(它们是小的png文件).你有什么建议?动态函数是理想的..有四个图标,每个图标的文件名为demo.png,demo_hover.png.我正在使用jQuery库.
谢谢!
HTML
<a class="a" id="interscope_icon" href="http://www.interscope.com/" alt="Interscope Records" target="_blank"><img class="icon" id="interscope" src="../Images/icons/interscope.png" alt="Interscope Records" /></a>
<a class="a" href="http://www.twitter.com/FernandoGaribay" alt="Twitter" target="_blank"><img class="icon" id="twitter" src="../Images/icons/twitter.png" alt="Fernando Garibay's Twitter" /></a>
</p>
<p>
<a class="a" href="http://www.facebook.com/f2inc" alt="Facebook" target="_blank"><img class="icon" id="facebook" src="../Images/icons/facebook.png" alt="Fernando Garibay's Facebook" /></a>
<a class="a" href="http://www.myspace.com/f2inc" alt="Myspace" target="_blank"><img class="icon" id="myspace" src="../Images/icons/myspace.png" alt="Fernando Garibay's Myspace" /></a>
</p>
Run Code Online (Sandbox Code Playgroud)
jQuery的
$('#interscope_icon').hover(function(){
$('#interscope').attr('src', 'Images/icons/interscope.png');
});
Run Code Online (Sandbox Code Playgroud) 我希望jQuery在我悬停一个元素后做一些事情并在鼠标上执行其他操作.
我写了这个:
jQuery('.item').hover(
function() {
var bg = jQuery(this).attr('data-background');
jQuery(this).css("background-color", bg);
},
function() { /* this doesn't seem to work */
alert(bg);
});
Run Code Online (Sandbox Code Playgroud)
你能告诉我为什么这个代码在第二个函数之前工作正常,所以它从不提醒任何东西?我相信有一个错字,但我找不到; /
我在jQuery中有这个悬停事件.这里有很多<li>标签
$("ul#mainnav li").hover(function(){
if($(this) == $("ul#mainnav li:eq(1)")){
alert("yes");
} else {
alert("no");
}
})
Run Code Online (Sandbox Code Playgroud)
这不起作用.谢谢您的帮助.
问题: 我想在一个li元素的子元素中添加一个类.
HTML代码:
<li class="active">
<a href="index.html" title="Homepage">Homepage<i class="icon-home"></i></a>
</li>
Run Code Online (Sandbox Code Playgroud)
jQuery代码:
<script type="text/javascript">
$(document).ready(function()
{
$('li[ class="active" ]').hover(
function(){ $(this).addClass('icon-white') },
function(){ $(this).removeClass('icon-white') }
)
});
</script>
Run Code Online (Sandbox Code Playgroud)
期望的结果:
<li class="active">
<a href="index.html" title="Homepage">Homepage<i class="icon-home icon-white"></i></a>
</li>
Run Code Online (Sandbox Code Playgroud)
将类添加到特定元素的代码:
<script type="text/javascript">
$(document).ready(function()
{
if ($('#main-nav > li').hasClass('active') == true)
{
$("a > i", this).addClass('icon-white');
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
更新(最终解决方案):
<script type="text/javascript">
$(document).ready(function()
{
$('#main-nav li').hover(function()
{
if ($(this).hasClass('active') != true)
{
$('a', this).find('i').toggleClass('icon-white');
}
});
$("#main-nav li.active > a > i").addClass('icon-white');
});
</script> …Run Code Online (Sandbox Code Playgroud) 我正在使用带有手动控件的flexslider,并且它正常工作.但是,当您将鼠标悬停在控件上时,我需要它们来更改幻灯片,而不是单击控件.这可能吗?我查看了js文件,找不到要更改的单击函数.
这是flexslider js:https://raw.github.com/woothemes/FlexSlider/master/jquery.flexslider.js
这是我的代码:
$(window).load(function(){
$('.flexslider').flexslider({
animation: "slide",
directionNav: true,
controlsContainer: "header#site",
manualControls: ".nav1 li"
});
});
Run Code Online (Sandbox Code Playgroud)
HTML是(简化)这个:
<header id="site">
<ul class="nav1">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
<div class="flexslider">
<ul class="slides">
<li>Image 1</li>
<li>Image 2</li>
<li>Image 3</li>
</ul>
</div>
</header>
Run Code Online (Sandbox Code Playgroud) 我目前拥有的代码是:
.button2 {
margin-left: 10px;
background-color: lightgreen;
width: 180px;
height:100px;
padding: 50px,60px;
color: rgba(20, 15, 30, 0.8);
text-transform: uppercase;
border: 1px solid green ;
font-weight: bold;
font-size: 20px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
-border-radius: 3px;
text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8), 0 -1px 0 rgba(25, 27, 9, 0.9);
-moz-box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.6), 0 5px 0 #3a79a4, 0 6px 0 #593a11, 0 13px 0 #ccc;
-webkit-box-shadow: inset …Run Code Online (Sandbox Code Playgroud) 你如何将鼠标悬停在一个单词上,右边它会显示更多的单词?
<div id="footer">
<center>
<p>Copyright 2014</p>
</center>
<center><a href="http://www.scriptiny.com/2010/09/fading-slideshow-script/" style="position:absolute; margin-top:20px; margin-left:-35px; text-decoration:none; color:gray; z-index:20;">Tinyfader.js</a> <p style=" margin-top:-38px;padding-top:20px; padding-left:572px; opacity:0; color:red; ">Released under Creative Commons License</p>
<center><a href="http://jquery.org/license" style="position: absolute; text-decoration:none; color:gray; margin-top:0px; margin-left:-50px; z-index:20;">Jquery-1.5.min.js</a> <p style="margin-top:-20px; padding-left:642px; opacity:0; color:red;">Dual licensed under the MIT or GPL Version 2 licenses</p>
<center><a href="http://jquery.org/license" style="position: absolute; text-decoration:none; color:gray; margin-top:0px; margin-left:-80px; z-index:20;">Jquery-ui-1.8.9.custom.min.js</a><p style="margin-top:-20px; padding-left:642px; opacity:0; color:red;">Dual licensed under the MIT or GPL Version 2 licenses</p>
<center><p style="margin-top:-18px;"><a href="http://sizzlejs.com/" style="position: absolute; text-decoration:none; color:gray; margin-top:-2px; margin-left:-25px; …Run Code Online (Sandbox Code Playgroud) 我有个问题。我制作了一个自定义html5 soundcloud播放器,并且有一个包含图像的播放列表。我想通过将鼠标悬停在图像上来显示图像的标题。
例如,我做了一个简单的jsfiddle:http : //jsfiddle.net/dC85Q/
目前,不透明度仅在我将鼠标移至标题div时才会更改。但是,当我将鼠标移至图像div时,它应该会改变。我知道使用javascript的可能性,但我不想为此使用javascript。有办法用CSS吗?
我的html:
<div id="song1" class="songs" onclick="song1()">
<div id="songtitle1" class="songtitles">Hello World</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我是CSS和HTML的新手,我想创建一个在悬停时快速放大的图像.但是盒子半径也会放大.我知道我的div课程出了问题,但我无法弄明白究竟是什么.
所以我的意思是我想要这样的效果:http: //designshack.net/tutorialexamples/imagehovers/zoomandpan.html (金发女郎一个)
这是相关代码:
#circle {
border: 4px solid;
height:200px;
width:200px;
border-color: #000;
border-radius: 100px;
}
.bolimg{
background: url('http://i60.tinypic.com/wb82e0.jpg') no-repeat;
height:200px;
width:200px;
-webkit-border-radius: 100px;
-webkit-transition: 2s ease-out;
-moz-transition: 2s ease-out;
-o-transition: 2s ease-out;
-ms-transition: 2s ease-out;
transition: 2s ease-out;
}
.bolimg:hover {
opacity:1;
background-image: url('http://i59.tinypic.com/k0szuv.jpg');
-webkit-transition: 2.5s ease-out;
-moz-transition: 2.5s ease-out;
-o-transition: 2.5s ease-out;
-ms-transition: 2.5s ease-out;
transition: 2.5s ease-out;
-webkit-transform:scale(1.25); /* Safari and Chrome */
-moz-transform:scale(1.25); /* Firefox */
-ms-transform:scale(1.25); /* IE 9 */
-o-transform:scale(1.25); /* …Run Code Online (Sandbox Code Playgroud) 我在散景图上有多行,我希望HoverTool显示每行的值,但使用前一个stackoverflow答案的方法不起作用:
以下是该答案的相关代码段:
fig = bp.figure(tools="reset,hover")
s1 = fig.scatter(x=x,y=y1,color='#0000ff',size=10,legend='sine')
s1.select(dict(type=HoverTool)).tooltips = {"x":"$x", "y":"$y"}
s2 = fig.scatter(x=x,y=y2,color='#ff0000',size=10,legend='cosine')
fig.select(dict(type=HoverTool)).tooltips = {"x":"$x", "y":"$y"}
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
from bokeh.models import HoverTool
from bokeh.plotting import figure
source = ColumnDataSource(data=dict(
x = [list of datetimes]
wind = [some list]
coal = [some other list]
)
)
hover = HoverTool(mode = "vline")
plot = figure(tools=[hover], toolbar_location=None,
x_axis_type='datetime')
plot.line('x', 'wind')
plot.select(dict(type=HoverTool)).tooltips = {"y":"@wind"}
plot.line('x', 'coal')
plot.select(dict(type=HoverTool)).tooltips = {"y":"@coal"}
Run Code Online (Sandbox Code Playgroud)
据我所知,它相当于我链接的答案中的代码,但当我将鼠标悬停在图上时,两个悬停工具框都显示相同的值,即wind.
hover ×10
jquery ×5
css ×4
html ×3
addclass ×1
bokeh ×1
border ×1
css3 ×1
flexslider ×1
html-lists ×1
if-statement ×1
image ×1
image-zoom ×1
javascript ×1
python ×1
python-3.x ×1
zoom ×1