【问题标题】:CSS: Image and text with inset shadow aligned inside a link (display:block) with gradient backgroundCSS:带有插入阴影的图像和文本在具有渐变背景的链接(显示:块)内对齐
【发布时间】:2013-03-16 14:57:49
【问题描述】:

喏,

我正在开发一个网络应用程序,我正在尝试获取一个可点击的 div(我通过 <a href...> 实现了这一点,在 css 中样式为“显示:块”,具​​有线性渐变。 没问题...

然后我想在这个<a...> 中插入一个图标,然后我用一个包含标志性字体的<p> 做到了... 再次没有问题...

然后我尝试在同一块内的图标/字体下方的 calibri 中插入一些不同的文本,并具有相同的样式(我希望有一个内部阴影,使事物看起来像是被“按下”)。 在这里我对结果不满意,因为我几乎无法对齐这两个元素(我将其样式为<p>,我应该改用<span> 吗?)。

作为示例,我想获得类似于 facebook 应用按钮但图像和文本垂直对齐的效果

Facebook div/link

我该怎么做?最佳做法是什么(标志性字体 + Photoshop 中的字体或图像 + css 中的字体,还是什么?)?

PS:那么漂亮的 2 行作为链接/div 的边框呢,它们的样式如何?

【问题讨论】:

  • 你能发布一些你的 HTML 和 CSS 的 sn-ps 吗?

标签: css html gradient shadow


【解决方案1】:

我认为最好的 - 用 photoshop 设计的图像 + 用 css 设计的字体 对于线条,尝试使用渐变和框阴影。 http://jsbin.com/esasan/1/edit

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div class="main">
    <ul class="lines">
      <li class="line"></li>
      <li class="line"></li>
    </ul>
  </div>
</body>
</html>

.main {
  display:block;
  position:relative;
  width:150px;
  height:70px;
  background: #fcfcfd; /* Old browsers */
background: -moz-linear-gradient(top,  #fcfcfd 0%, #eaecf2 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fcfcfd), color-stop(100%,#eaecf2)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #fcfcfd 0%,#eaecf2 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #fcfcfd 0%,#eaecf2 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #fcfcfd 0%,#eaecf2 100%); /* IE10+ */
background: linear-gradient(to bottom,  #fcfcfd 0%,#eaecf2 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfd', endColorstr='#eaecf2',GradientType=0 ); /* IE6-9 */
   -moz-box-sizing: border-box; 
    box-sizing: border-box; 
  -webkit-box-sizing: border-box;
}

.lines{
  position:relative;
  width:150px;
  height:64px;
  margin-top:3px;
}

.lines li {
  display:inline-block;
  margin-top:4px;
}

.line {
  width:2px;
  height:60px;
  background: #9fa0a3; /* Old browsers */
background: -moz-radial-gradient(center, ellipse cover,  #9fa0a3 0%, #f4f6fc 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#9fa0a3), color-stop(100%,#f4f6fc)); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover,  #9fa0a3 0%,#f4f6fc 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center, ellipse cover,  #9fa0a3 0%,#f4f6fc 100%); /* Opera 12+ */
background: -ms-radial-gradient(center, ellipse cover,  #9fa0a3 0%,#f4f6fc 100%); /* IE10+ */
background: radial-gradient(ellipse at center,  #9fa0a3 0%,#f4f6fc 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9fa0a3', endColorstr='#f4f6fc',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */
  margin-right:60px; 
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 2012-10-15
    • 2012-06-25
    相关资源
    最近更新 更多