我有这样的结构:
<div id="container">
<span>
<span></span>
</span>
<span>
<span></span>
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要捕获容器的mouseout事件,所以我让jquery这样做:
$("#container").hover('',function(){
alert("Out");
});
Run Code Online (Sandbox Code Playgroud)
在Firefox/Opera中,它只在离开div时触发mouseout-function(我多么想要它).
在IE中,它会在鼠标命中的div内的每个*-Tag处触发mouseout-function.(*可能很重要的是,span标签还有mouseover和out事件)
任何人都知道如何解决这个问题?(由于复杂的布局,嵌套结构无法更改)
thx4任何想法!
我有动态评论列表:
<div class="comment">
<div class="commentact">
Test1
</div>
</div>
<div class="comment">
<div class="commentact">
Test2
</div>
</div>
<div class="comment">
<div class="commentact">
Test3
</div>
</div>?
Run Code Online (Sandbox Code Playgroud)
现在我需要当用户悬停每个div class='comment'节目div class='commentact'时opacity 0.
我有这个jquery函数:(我设置div commentact默认为不透明度0.2)
$(".commentact").css('opacity','0.2');
$(document).ready(function(){
$(".comment").hover(function() {
$(".commentact").stop().animate({ opacity: 1 });
}, function() {
$(".commentact").stop().animate({ opacity: 0.2 });
});
});?
Run Code Online (Sandbox Code Playgroud)
现在当我悬停comment div显示所有commentact div不透明度为0时,有什么问题!怎么解决这个问题?演示
我一直认为iOS设备上的悬停效果仅在完整的"点击"(或"触摸")上可见,但后来我找到了这个页面:
http://www.theverge.com/2013/2/19/4004250/sunrise-for-iphone-calendar-app-for-a-post-google-world
这里悬停效果是可见的,当我点击一个元素(没有延迟),当我离开我的手指时离开 - 没有必要完成点击.
我不明白.诀窍是什么?
我有以下页面:
<!DOCTYPE html>
<html>
<head>
<title>The Divine Liturgy</title>
<meta charset='utf-8'>
<style type='text/css'>
body
{
font-family: Verdana, Arial, sans;
}
.ui-tooltip, .ui-widget, .ui-corner-all, .ui-widget-content,
.ui-tooltip-content
{
background-color: #ffff00;
width: 800px;
}
</style>
<link rel='stylesheet' type='text/css'
href='/js/jquery-ui-1.10.2.custom/css/smoothness/jquery-ui-1.10.2.custom.css'
/>
</head>
<body>
<p title="Bless, Master!">Deacon: Blagoslavie, Vladyko!</p>
<p title="Blessed is the Kingdom of the Father, and of the Son, and of the Holy Spirit: Now and ever, and unto the ages of ages.">Priest: Blagoslovenno tsarsvo Otsa i Sina, i Svatago Duha, nine e presno, …Run Code Online (Sandbox Code Playgroud) 我试图制作一组按钮,我创建了标准按钮,当然我想要一个悬停效果,但我正在做的方式,渐变似乎没有改变到悬停状态.
.sqaure-blue-btn {
border: 1px solid #2f78a9; /* stroke */
background-color: #3999d7; /* layer fill content */
-moz-box-shadow: inset 0 1px 1px #82cdff; /* inner shadow */
-webkit-box-shadow: inset 0 1px 1px #82cdff; /* inner shadow */
box-shadow: inset 0 1px 1px #82cdff; /* inner shadow */
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iaGF0MCIgZ3JhZGllbnRVbml0cz0ib2JqZWN0Qm91bmRpbmdCb3giIHgxPSI1MCUiIHkxPSIxMDAlIiB4Mj0iNTAlIiB5Mj0iLTEuNDIxMDg1NDcxNTIwMmUtMTQlIj4KPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzMzODViYyIgc3RvcC1vcGFjaXR5PSIxIi8+CjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzNhOWFkYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgIDwvbGluZWFyR3JhZGllbnQ+Cgo8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgZmlsbD0idXJsKCNoYXQwKSIgLz4KPC9zdmc+); /* gradient overlay */
background-image: -moz-linear-gradient(bottom, #3385bc 0%, #3a9ada 100%); /* gradient overlay */
background-image: -o-linear-gradient(bottom, #3385bc 0%, #3a9ada 100%); /* gradient overlay */
background-image: -webkit-linear-gradient(bottom, #3385bc 0%, #3a9ada 100%); /* …Run Code Online (Sandbox Code Playgroud) 我几乎不敢问这个问题,因为它似乎是一个显而易见的问题,但我找不到一个明确的答案,所以冒着玷污我不存在的声誉的风险,这里有:
有没有办法在悬停时向图像添加扩展的CSS内边框,而不影响图像的大小?
这是我的代码尽可能接近我自己:
CSS
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.media_item_container img {
border: 3px solid #00205f;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
}
.media_item_container img:hover {
border: 10px solid #00205f;
}
.media_item_container a
{
font-weight:bold;
color:#000;
text-decoration:none;
font-size:13px;
}
.media_item_container a:hover
{
color:#fff;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<body bgcolor="#999999">
<div class="media_item_container">
<div class="media_item_text">
<a href="#"><img src="http://lorempixel.com/output/business-q-c-158-158-5.jpg" width="158" height="158" class="media_item_thumb" />
<h3>E-Brochure: <em>Printable …Run Code Online (Sandbox Code Playgroud) 现在让我们看看,不确定我是否有100%的逻辑.
这就是我正在使用的(这里的 bootply演示)
<ul>
<li class="row">
<span class="category col-sm-2 highlight">Architecture</span>
<span class="title col-sm-4"><a href="#">Hello world!</a></span>
<span class="publication col-sm-2 hidden-xs">Magazine</span>
<span class="year col-sm-2 hidden-xs">2007</span>
</li>
<li class="row">
<span class="category col-sm-2 invisible">Architecture</span>
<span class="title col-sm-4"><a href="#">Keep them coming</a></span>
<span class="publication col-sm-2 hidden-xs">Magazine</span>
<span class="year col-sm-2 hidden-xs">2007</span>
</li>
<li class="row">
<span class="category col-sm-2 invisible">Architecture</span>
<span class="title col-sm-4"><a href="#">The other posts</a></span>
<span class="publication col-sm-2 hidden-xs">Magazine</span>
<span class="year col-sm-2 hidden-xs">2007</span>
</li>
<li class="row">
<span class="category col-sm-2">Cities</span>
<span class="title col-sm-4"><a href="#">Tezt</a></span>
<span class="publication col-sm-2 hidden-xs">Magazine</span> …Run Code Online (Sandbox Code Playgroud) 我写了一个简单的工具提示功能,在这里可以看到.
问题是,在.hover()我设置的两个处理函数中,我需要访问$(this)基于它的其他2个变量.为了实现这一点,我在两个处理程序中声明了相同的3个变量:
$('a').hover(
function () {
var $this = $(this);
var link_offset = $this.offset();
var link_tooltip = $this.data('tooltip');
// Rest of the code
},
function () {
var $this = $(this);
var link_offset = $this.offset();
var link_tooltip = $this.data('tooltip');
// Rest of the code
}
);
Run Code Online (Sandbox Code Playgroud)
DRY原则应该得到尊重,所以我的问题是:是否有其他更聪明/更脏的方法将相同的变量集传递给两个函数.hover()?
显而易见,变量不能是全局的(无论如何全局变量都是邪恶的).
任何想法如何用jQuery或纯JS实现这一点?
我正在尝试创建一个小动画,所以当我将鼠标悬停在一个链接上时,它强调了来自中间的链接 - JS Fiddle
下面的CSS代码有效,但我不明白它是如何工作的.请有人可以帮我分解.
a {
display: inline-block;
position: relative;
padding-bottom: 3px;
}
a:after {
content: '';
display: block;
margin: auto;
height: 3px;
width: 0px;
background: transparent;
transition: width .5s ease, background-color .5s ease;
}
a:hover:after {
width: 100%;
background: blue;
}
Run Code Online (Sandbox Code Playgroud) 我想建立一个固定的<div>,含有图标,它由右扩展到左时被悬停(该<div>膨胀时,未图标),露出在该图标的左侧的一段文字.图标的位置保持不变.这是一个草图,以帮助说明我想做的事情:
更改<div>悬停的大小没有问题,我只需添加一个宽度更大的类(包括转换为扩展设置动画).但我对元素的定位感到困惑.我将图标和文本(在一个内部<span>)分开放置<div>并尝试使用安排一切flex.在扩展/悬停状态下,事情看起来应该是这样,但是一旦<div>再次缩小,包含图标和文本的两个div会尝试共享剩下的小空间,因此图标会被切断,文本会被压缩.
如果有人能帮助我弄清楚如何按照我希望的方式设置它,我将不胜感激.
这是我到目前为止所获得的jsFiddle:Button-GrowOnHover
加上代码本身:
$(document).ready(function() {
var button = $("#myButton");
button.mouseenter(function() {
$(this).addClass("grow");
});
button.mouseleave(function() {
$(this).removeClass("grow");
});
});Run Code Online (Sandbox Code Playgroud)
.button-container {
position: fixed;
top: 5%;
right: 5%;
width: 100px;
padding: 5px;
background-color: tomato;
display: flex;
justify-content: space-between;
overflow: hidden;
transition: width 1s;
}
.button-container.grow {
width: 300px
}
.button-text-container {
display: flex;
align-items: center;
justify-content: center;
background-color: lightblue;
}
.button-icon-container {
height: …Run Code Online (Sandbox Code Playgroud)