forms - 是否可以使用 CSS3 制作尖头按钮(类似苹果)?

标签 forms css

我想用 CSS3 制作一个类似 iPhone 后退按钮的按钮

这可能吗?怎么办?

你可以看到我的目标here :

iPhone back button

最佳答案

这是一个可能的解决方案,主要使用 CSS2(只需为 border-radius 和 box-shadow 使用一些可选的 CSS3)。这是一个有限的、直接的解决方案,似乎适用于当前版本(截至 2012 年 11 月)的 Chrome 和 Firefox,同样在 IE7-9 中呈现几乎相同。我没有要测试的 IE10,但可以合理地假设它没问题。

我写“受限”是因为这些按钮必须使用纯色背景才能在浏览器中呈现相同的效果。此外,box-shadow 并没有完全延伸到“点”,但谨慎使用它可能不会令人反感。 Box-shadow 无论如何都是可选的,因为它在旧的 IE 上不受支持,除非增加类似 CSS3Pie 的东西.

http://jsfiddle.net/yHprm/11/

.wiz-buttons > a {
  position: relative;
  display: block;
  font: normal 14px Arial;
  text-decoration: none;
  cursor: pointer;
}
.wiz-buttons > a > .button {
  min-width: 75px;
}
/* Next Button */

.wiz-buttons > .next {
  color: #FFF;
}
.wiz-buttons > .next > .arrow-inner {
  display: block;
  position: absolute;
  top: 1px;
  right: 3px;
  z-index: 2000;
  width: 0;
  height: 0;
  border: 14px solid transparent;
  border-left-color: #E38A13;
}
.wiz-buttons > .next > .arrow {
  display: block;
  float: right;
  width: 0;
  height: 0;
  border: 15px solid transparent;
  border-left-color: #CC790B;
}
.wiz-buttons > .next > .button {
  display: block;
  float: right;
  line-height: 20px;
  background-color: #E38A13;
  border: 2px solid #CC790B;
  border-right: 0;
  padding: 3px 3px 3px 9px;
  text-align: center;
  -webkit-border-radius: 2px 0 0 2px;
  -moz-border-radius: 2px 0 0 2px;
  border-radius: 2px 0 0 2px;
  filter: progid: DXImageTransform.Microsoft.gradient(enabled=false);
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.wiz-buttons > .next:hover > .arrow {
  border-left-color: #ad6608;
}
.wiz-buttons > .next:hover > .arrow-inner {
  border-left-color: #CC790B;
}
.wiz-buttons > .next:hover > .button {
  background-color: #CC790B;
  border-color: #b66c09;
}
/* Previous Button */

.wiz-buttons > .previous {
  color: #666;
}
.wiz-buttons > .previous > .arrow-inner {
  display: block;
  position: absolute;
  top: 1px;
  left: 3px;
  z-index: 2000;
  width: 0;
  height: 0;
  border: 14px solid transparent;
  border-right-color: #f4f4f4;
}
.wiz-buttons > .previous > .arrow {
  display: block;
  float: left;
  width: 0;
  height: 0;
  border: 15px solid transparent;
  border-right-color: #e8e8e8;
}
.wiz-buttons > .previous > .button {
  display: block;
  float: left;
  line-height: 20px;
  background-color: #f6f6f6;
  border: 2px solid #eaeaea;
  border-left: 0;
  padding: 3px 9px 3px 3px;
  text-align: center;
  -webkit-border-radius: 0 2px 2px 0;
  -moz-border-radius: 0 2px 2px 0;
  border-radius: 0 2px 2px 0;
  filter: progid: DXImageTransform.Microsoft.gradient(enabled=false);
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.wiz-buttons > .previous:hover > .arrow {
  border-right-color: #e1e1e1;
}
.wiz-buttons > .previous:hover > .arrow-inner {
  border-right-color: #eaeaea;
}
.wiz-buttons > .previous:hover > .button {
  background-color: #eaeaea;
  border-color: #e3e3e3;
}
<div class="wiz-buttons">
  <a class="previous" href="#">
    <span class="arrow"></span>
    <span class="arrow-inner"></span>
    <span class="button">Previous</span>
  </a>
  <a class="next" href="#">
    <span class="arrow"></span>
    <span class="arrow-inner"></span>
    <span class="button">Next</span>
  </a>
</div>

我希望有人觉得这很有用。

关于forms - 是否可以使用 CSS3 制作尖头按钮(类似苹果)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6789943/

相关文章:

html - Angular 2 - 基本表单验证不再有效

jquery - 将带有 onchange 的选择转换为 ul 和 jquery

python - Django CSRF验证失败

css - 将两个对象与 css 位置 :absolute; (without fixed margin-left or left properties) 对齐

jquery - 如何使用 jQuery 上的点击功能更改 div 的 css,但是两次而不是一次?

javascript - CSS+JS : div click (and elements inside it)

javascript - 如何使 php 提交按钮跟随带参数的 URL 与 Echo(当前设置)?

database - MS Access 表单无需子表单即可更新多个表

html - 如何让这个 SVG 图形自动适应它的容器?

css - 使用 ANT 运行框架时单击 CSS 菜单