html - CSS 在文本旁边添加社交图标

标签 html css

这是我的 jsfiddle DEMO

我需要在“关注我们”文本下添加社交图标。

我必须处理每个链接。但我只有一张图片..

所以我需要设置类似的位置。但我只是困惑如何设置。

HTML

  <div class="social-bar">        
      <p class="follow-us">Follow Us</p>
      <a>
        <img src="http://s13.postimg.org/63sed3cjn/social_icons.png" />
     </a>    
  </div>

谁能帮我解决这个问题吗?

谢谢

最佳答案

您可以使用背景图像demo fiddle

HTML:

<div class="social-bar">
  <p class="follow-us">
    <span class="follow">Follow Us</span>
    <a href="#" class="social fb"></a>
    <a href="#" class="social twitter"></a>
    <a href="#" class="social google"></a>
    <a href="#" class="social pinterest"></a>
  </p>
</div>

CSS:

.social-bar{
  border-top:1px solid red;
  width:922px;
  background-color:#ef9d9d;
  border-radius: 3px;
  border: 1px solid #e48181; 
  height:49px;
  margin:0 auto;
  margin-bottom:20px;
  position: relative;
}
.social-bar p{
  font-family:Arial;
  font-size:16px;
  color: #fff;
  margin-left:10px;
}
.social {
    background-image: url(http://s13.postimg.org/63sed3cjn/social_icons.png);
    display: inline-block;
    width: 25px;
    height: 25px;
}

.social.twitter {
    background-position: -35px 0;
}

.social.google {
    background-position: -70px 0;
}

.social.pinterest {
    background-position: -100px 0;
}

关于html - CSS 在文本旁边添加社交图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30861265/

相关文章:

javascript - 制作一个不滚动 body 其余部分的可滚动div

html - 如何居中 <u> html 元素?

css - 有什么方法可以使用带有 CSS 选择器的文本来定位 Web 元素吗?

javascript - 将事件类添加到菜单部分

android - HTML 内的可滚动内容不会在 Android 模拟器或手机中滚动

javascript - 无论字体系列如何,Firefox 中的字体总是比 Chrome 更粗

javascript - jQuery 向下查找多个级别的子元素

通过下拉列表接收的 JQuery 变量未应用 css

javascript - 单击按钮时使字段可编辑

php - 我的 CSS 没有正确应用于我的 PHP 包含文件