首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >雪碧图像没有在css中剪切。

雪碧图像没有在css中剪切。
EN

Stack Overflow用户
提问于 2013-08-12 19:38:54
回答 3查看 136关注 0票数 0

因此,我试图为我们的媒体的底层链接做一个精灵图像,而我没有让这个图像得到适当的裁剪,我的错误在哪里?

CSS

代码语言:javascript
复制
.footer{
    position:absolute;
    bottom:0px;
    margin:5px;
    border:2px solid grey;
    width:200px;
    height:55px;
    overflow:hidden;
    display:block;
}

#twitter{
    background:url('http://unifiedforunifat.com/redesign/resources/social.jpg') no-repeat;
    height:50px;
    width:50px;
    background-position: 0 0;
    display:block;
}

#twitter a:hover{
    background:url('http://unifiedforunifat.com/redesign/resources/social.jpg');
    background-position: 0 50px;
}

HTML:

代码语言:javascript
复制
<div class="footer">
<a href="https://twitter.com/unified4unifat" id="twitter" class="imglink" >
<img src="http://unifiedforunifat.com/redesign/resources/social.jpg" alt="U4U's Twitter"
/>
</a>
</div>
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-08-12 19:52:02

我做到了(尽管您可能不需要!重要的标记):http://jsfiddle.net/NV6zw/6/

代码语言:javascript
复制
<div class="footer">
<a href="https://twitter.com/unified4unifat" id="twitter" class="imglink" ></a>

代码语言:javascript
复制
.footer{

margin:5px;
border:2px solid grey;
width:200px;
height:55px;
overflow:hidden;
display:block;
}
#twitter{
    background:url('http://unifiedforunifat.com/redesign/resources/social.jpg') no-repeat;
    height:50px;
    width:50px;
    background-position: 0 0;
    display:block;
}
#twitter:hover{
    background:url('http://unifiedforunifat.com/redesign/resources/social.jpg');
    background-position: -50px 0 !important;
} 
票数 0
EN

Stack Overflow用户

发布于 2013-08-12 19:46:09

如果您只想在带类的页脚中显示一个twitter图片,则需要将.footer宽度设置为50 to,而不是整个图像的200 to。

票数 0
EN

Stack Overflow用户

发布于 2013-08-12 20:06:20

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <title></title>
  <style type="text/css">
    .footer{
    position:absolute;
    bottom:0px;
    margin:5px;
    border:2px solid grey;
    height:55px;
    overflow:hidden;
    display:block;
   }

   #twitter{
     background:url('http://unifiedforunifat.com/redesign/resources/social.jpg') no-
     repeat;
     height:50px;
     width:50px;
     background-position: 0 0;
     display:block;
   }

   #twitter a:hover{
   background:url('http://unifiedforunifat.com/redesign/resources/social.jpg');
   background-position: 0 50px;
  }
  </style>
</head>
<body>
  <div class="footer">
    <a href="https://twitter.com/unified4unifat" id="twitter" class="imglink" >
    <!--<img src="http://unifiedforunifat.com/redesign/resources/social.jpg" alt="U4U's     
    Twitter"-->
    <!--/>-->
       <div style="background:  
         url('http://unifiedforunifat.com/redesign/resources/social.jpg');width: 
         50px;height:50px; background-repeat: no-repeat"></div>
    </a>
  </div>
 </body>
 </html>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18195327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档