简体   繁体   English

CSS按钮精灵

[英]Css button sprite

I'm trying to get this Sprite done, but i'm stuck and can't figure out a solution. 我正在尝试完成此Sprite,但我遇到了麻烦,无法找到解决方案。

FIDDLE HERE 在这里

I have a simple button: 我有一个简单的按钮:

<a href="#" class="ui-button sub-beta-button">
  <span class="button-content">Beta Sign-Up</span>
</a>

and the css: 和CSS:

.sub-beta-button {
  height: 78px;
  background: transparent url("http://i.imgur.com/PSpIGLA.png") 100% -160px no-repeat;
  padding-right: 50px;
  margin-left: 30px;
  bottom: 18px;
  z-index: 1;
  position: relative;
}

.ui-button {
  background: 0;
  border: 0;
  cursor: pointer;
  display: inline-block;
  height: auto;
  overflow: visible;
  padding: 0;
  margin: 0;
  vertical-align: middle;
  outline: 0;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}
.sub-beta-button .button-content {
  background-image: url("http://i.imgur.com/PSpIGLA.png");
  padding-left: 50px;
  color: #fff;
  font: normal normal 18px/86px "Bliz Quadrata", Times New Roman;
  text-transform: uppercase;
  text-shadow: 0 0 4px #000, 0 0 8px #000;
  overflow: hidden;
  min-width: 110px;
  margin-left: -30px;
  height: 76px;
  z-index: 2;
}
.ui-button span {
  outline: 0;
  display: inline-block;
  background-repeat: no-repeat;
}

but i'm getting only this result: 但我只得到这个结果:

在此处输入图片说明

That's the Sprite: 那就是雪碧:

在此处输入图片说明

FIDDLE HERE 在这里

your .ui-button class removes the background ( background: 0 ). 您的.ui-button类将删除背景( background: 0 )。

You can better first get the button working without the ui-button class, and then rule by rule fill up the ui-button class. 您最好先使按钮在没有ui-button类的情况下工作,然后再按规则填充ui-button类。 That way you are sure you are using minimal and correct css. 这样,您可以确定使用的是最小正确的CSS。

I've made an edit and removed all the junk code. 我进行了修改,并删除了所有垃圾代码。 If you want the text to the center, edit padding-left and add text align:center 如果要将文本居中,请编辑padding-left并添加align:center

padding-left

and change it to 并将其更改为

 text-align:center

http://jsfiddle.net/va854 http://jsfiddle.net/va854

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM