如何将此按钮旋转180°?

时间:2015-04-04 12:06:17

标签: css

我正在尝试在css按钮中旋转箭头,但我无法在不旋转整个按钮的情况下继续...

关键是从上传按钮制作下载按钮。如何只旋转箭头?

按钮:

body {
  background: #2d3e4f;
}
.cntr {
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  -o-transform: translate(-50%, -50%);
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
.upload {
  display: block;
  width: 40px;
  height: 50px;
  -webkit-border-radius: 2px;
  border-radius: 2px;
  background: #e64d43;
  cursor: pointer;
}
.upload:after {
  content: '';
  position: absolute;
  display: block;
  top: 0px;
  right: 0px;
  width: 0px;
  height: 0px;
  -webkit-border-radius: 0px 2px 0px 2px;
  border-radius: 0px 2px 0px 2px;
  background: -webkit-linear-gradient(45deg, #c5251a 50%, #2d3e4f 50%);
  background: -moz-linear-gradient(45deg, #c5251a 50%, #2d3e4f 50%);
  background: -o-linear-gradient(45deg, #c5251a 50%, #2d3e4f 50%);
  background: -ms-linear-gradient(45deg, #c5251a 50%, #2d3e4f 50%);
  background: linear-gradient(45deg, #c5251a 50%, #2d3e4f 50%);
  -webkit-transition: all 0.2s linear;
  -moz-transition: all 0.2s linear;
  -o-transition: all 0.2s linear;
  -ms-transition: all 0.2s linear;
  transition: all 0.2s linear;
}
.upload i {
  width: 2px;
  height: 14px;
  background: #fff;
  display: block;
  -webkit-border-radius: 2px;
  border-radius: 2px;
  -webkit-transition: all 150ms linear;
  -moz-transition: all 150ms linear;
  -o-transition: all 150ms linear;
  -ms-transition: all 150ms linear;
  transition: all 150ms linear;
}
.upload i:before,
.upload i:after {
  content: '';
  position: absolute;
  display: block;
  width: 2px;
  height: 8px;
  background: #fff;
  -webkit-border-radius: 2px;
  border-radius: 2px;
  -webkit-transition: all 150ms linear;
  -moz-transition: all 150ms linear;
  -o-transition: all 150ms linear;
  -ms-transition: all 150ms linear;
  transition: all 150ms linear;
}
.upload i:before {
  -webkit-transform: rotate(45deg) translateX(-3px);
  -moz-transform: rotate(45deg) translateX(-3px);
  -o-transform: rotate(45deg) translateX(-3px);
  -ms-transform: rotate(45deg) translateX(-3px);
  transform: rotate(45deg) translateX(-3px);
}
.upload i:after {
  -webkit-transform: rotate(-45deg) translateX(3px);
  -moz-transform: rotate(-45deg) translateX(3px);
  -o-transform: rotate(-45deg) translateX(3px);
  -ms-transform: rotate(-45deg) translateX(3px);
  transform: rotate(-45deg) translateX(3px);
}
.upload:hover i {
  height: 18px;
}
.upload:hover:after {
  width: 12px;
  height: 12px;
}

1 个答案:

答案 0 :(得分:0)

有几种更有效的方法可以做到这一点。

a)略过所有这些并使用工具创建一个原始图像旋转180度的备用按钮图像。

b)改为使用其中一个NUMEROUS Unicode字符。请参阅此维基百科页面:http://en.wikipedia.org/wiki/Arrow_(symbol)