Html 如何使用精灵将图像显示在悬停图像上
在将鼠标悬停在图像底部的图像上之后,我试图使一些线条出现(比如说大约10px) 我在MTV的每篇文章下面的“你也会喜欢这些”部分看到了这一点。他们使用css背景精灵来做到这一点 在多次尝试重新创建失败后,我都快发疯了。除了主悬停线出现之外,一切都正常。 这是我到目前为止的工作 CSS HTMLHtml 如何使用精灵将图像显示在悬停图像上,html,css,css-sprites,Html,Css,Css Sprites,在将鼠标悬停在图像底部的图像上之后,我试图使一些线条出现(比如说大约10px) 我在MTV的每篇文章下面的“你也会喜欢这些”部分看到了这一点。他们使用css背景精灵来做到这一点 在多次尝试重新创建失败后,我都快发疯了。除了主悬停线出现之外,一切都正常。 这是我到目前为止的工作 CSS HTML 任何帮助都将不胜感激。谢谢这是HTML: 替换http://yoururl使用您的url <div class="container"> <a href="http://y
任何帮助都将不胜感激。谢谢这是HTML: 替换
http://yoururl
使用您的url
<div class="container">
<a href="http://yoururl" id="internal_image"><span></span></a>
</div>
编辑:添加示例:这是HTML: 替换
http://yoururl
使用您的url
<div class="container">
<a href="http://yoururl" id="internal_image"><span></span></a>
</div>
编辑:添加示例:这是HTML: 替换
http://yoururl
使用您的url
<div class="container">
<a href="http://yoururl" id="internal_image"><span></span></a>
</div>
编辑:添加示例:这是HTML: 替换
http://yoururl
使用您的url
<div class="container">
<a href="http://yoururl" id="internal_image"><span></span></a>
</div>
编辑:添加示例::您可以做的简单操作是在悬停的图像上设置边框 i、 e 加价
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
</div>
如果您坚持要使用背景图像而不是边框,您可以这样做
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
<div class="shiny-border"></div>
</div>
.image-container {
display: inline-block;
position: relative;
}
.image-container img {
width: 100px;
height: 100px;
}
.image-container .shiny-border {
position: absolute;
top: 90px; //subtract the height of the shiny-border from 100px which is the height // to have the inset effect of the image
height: 10px;
width: 100%;
display: none;
}
.image-container img:hover + .shiny-border {
display: block;
background-image: url(../styles/images/Hydrangeas.jpg);
}
.图像容器{
显示:内联块;
位置:相对位置;
}
.图像容器img{
宽度:100px;
高度:100px;
}
.图像容器.闪亮的边框{
位置:绝对位置;
top:90px;//从100px减去闪亮边框的高度,即高度//以获得图像的插入效果
高度:10px;
宽度:100%;
显示:无;
}
.图像容器img:悬停+闪亮边框{
显示:块;
背景图像:url(../styles/images/hydangeas.jpg);
}
最简单的方法是在悬停图像上设置边框
i、 e
加价
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
</div>
如果您坚持要使用背景图像而不是边框,您可以这样做
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
<div class="shiny-border"></div>
</div>
.image-container {
display: inline-block;
position: relative;
}
.image-container img {
width: 100px;
height: 100px;
}
.image-container .shiny-border {
position: absolute;
top: 90px; //subtract the height of the shiny-border from 100px which is the height // to have the inset effect of the image
height: 10px;
width: 100%;
display: none;
}
.image-container img:hover + .shiny-border {
display: block;
background-image: url(../styles/images/Hydrangeas.jpg);
}
.图像容器{
显示:内联块;
位置:相对位置;
}
.图像容器img{
宽度:100px;
高度:100px;
}
.图像容器.闪亮的边框{
位置:绝对位置;
top:90px;//从100px减去闪亮边框的高度,即高度//以获得图像的插入效果
高度:10px;
宽度:100%;
显示:无;
}
.图像容器img:悬停+闪亮边框{
显示:块;
背景图像:url(../styles/images/hydangeas.jpg);
}
最简单的方法是在悬停图像上设置边框
i、 e
加价
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
</div>
如果您坚持要使用背景图像而不是边框,您可以这样做
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
<div class="shiny-border"></div>
</div>
.image-container {
display: inline-block;
position: relative;
}
.image-container img {
width: 100px;
height: 100px;
}
.image-container .shiny-border {
position: absolute;
top: 90px; //subtract the height of the shiny-border from 100px which is the height // to have the inset effect of the image
height: 10px;
width: 100%;
display: none;
}
.image-container img:hover + .shiny-border {
display: block;
background-image: url(../styles/images/Hydrangeas.jpg);
}
.图像容器{
显示:内联块;
位置:相对位置;
}
.图像容器img{
宽度:100px;
高度:100px;
}
.图像容器.闪亮的边框{
位置:绝对位置;
top:90px;//从100px减去闪亮边框的高度,即高度//以获得图像的插入效果
高度:10px;
宽度:100%;
显示:无;
}
.图像容器img:悬停+闪亮边框{
显示:块;
背景图像:url(../styles/images/hydangeas.jpg);
}
最简单的方法是在悬停图像上设置边框
i、 e
加价
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
</div>
如果您坚持要使用背景图像而不是边框,您可以这样做
<div class="image-container">
<img src="../styles/images/Desert.jpg" />
<div class="shiny-border"></div>
</div>
.image-container {
display: inline-block;
position: relative;
}
.image-container img {
width: 100px;
height: 100px;
}
.image-container .shiny-border {
position: absolute;
top: 90px; //subtract the height of the shiny-border from 100px which is the height // to have the inset effect of the image
height: 10px;
width: 100%;
display: none;
}
.image-container img:hover + .shiny-border {
display: block;
background-image: url(../styles/images/Hydrangeas.jpg);
}
.图像容器{
显示:内联块;
位置:相对位置;
}
.图像容器img{
宽度:100px;
高度:100px;
}
.图像容器.闪亮的边框{
位置:绝对位置;
top:90px;//从100px减去闪亮边框的高度,即高度//以获得图像的插入效果
高度:10px;
宽度:100%;
显示:无;
}
.图像容器img:悬停+闪亮边框{
显示:块;
背景图像:url(../styles/images/hydangeas.jpg);
}
我为您制作了working fiddle,您的html中没有额外的不需要的标记:
您的HTML:
<a href="#" class="hoverable">
<img src="http://placekitten.com/g/300/300" />
</a>
我为您制作了working fiddle,在html中没有额外的不需要的标记: 您的HTML:
<a href="#" class="hoverable">
<img src="http://placekitten.com/g/300/300" />
</a>
我为您制作了working fiddle,在html中没有额外的不需要的标记: 您的HTML:
<a href="#" class="hoverable">
<img src="http://placekitten.com/g/300/300" />
</a>
我为您制作了working fiddle,在html中没有额外的不需要的标记: 您的HTML:
<a href="#" class="hoverable">
<img src="http://placekitten.com/g/300/300" />
</a>
添加边框适用于整个布局,当您将鼠标悬停在其上时,会使其跳跃。@jimmyweb:Thatsy div是绝对定位的。所以没有什么会从球场上跳下来是的,你是对的。但在现实生活中的一个例子中(比如说一排类似的链接),它会打破这种局面,这到底是怎么发生的呢?你能解释一下吗?这不会发生的。图像容器是相对放置的。这意味着绝对定位的元素子元素相对于父元素进行定位。它不会溢出来。它不会破裂。不要担心添加边框会应用于整个布局,当您将鼠标悬停在上面时会使其跳跃。@jimmyweb:thasy div是绝对定位的。所以没有什么会从球场上跳下来是的,你是对的。但在现实生活中的一个例子中(比如说一排类似的链接),它会打破这种局面,这到底是怎么发生的呢?你能解释一下吗?这不会发生的。图像容器是相对放置的。这意味着绝对定位的元素子元素相对于父元素进行定位。它不会溢出来。它不会破裂。不要担心添加边框会应用于整个布局,当您将鼠标悬停在上面时会使其跳跃。@jimmyweb:thasy div是绝对定位的。所以没有什么会从球场上跳下来是的,你是对的。但在现实生活中的一个例子中(比如说一排类似的链接),它会打破这种局面,这到底是怎么发生的呢?你能解释一下吗?这不会发生的。图像容器是相对放置的。这意味着绝对的