首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在android中制作这样的径向浮动动作按钮?

如何在android中制作这样的径向浮动动作按钮?
EN

Stack Overflow用户
提问于 2018-05-31 06:13:26
回答 1查看 559关注 0票数 0

我目前是android设计和材料设计的新手。如果有人能帮助我制作一个像这样的径向浮动动作的机器人按钮,那就太好了

https://codepen.io/mblode/pen/pvVpaE

HTML

代码语言:javascript
复制
<div class="container"><div class="row"><div class="col-sm-12">
  <h1 class="text-center">Radial Floating Action Button</h1>
  <p class="text-center">(click)</p>
</div></div></div>

<div class="radial">
  <button class="fa fa-paper-plane fa-3x" id="fa-1"></button>
  <button class="fa fa-home fa-3x" id="fa-2"></button>
  <button class="fa fa-search fa-3x" id="fa-3"></button>
  <button class="fab">
    <div class="fa fa-plus fa-3x" id="plus"></div>
  </button>
</div> 

CSS

代码语言:javascript
复制
@import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Lato:300,400,700);

$font-stack: 'Lato', sans-serif;

* { box-sizing: border-box; }

$red: #ff4081;

body {
  font-family: $font-stack;
  background: #efefef;
}

button:focus {
  outline: 0;
}

.radial {
  width: 100px;
  height: 100px;
  position: fixed;
  right: 25px;
  bottom: 25px;
  background: $red;
  border-radius: 50%;
  transition: all 0.5s;
  box-shadow: 0px 2px 4px rgba(0,0,0,0.15), 0px 4px 8px rgba(0,0,0,0.2);
}

.fab {
  border: none;
  color: white;
  background-color: #ff4081;
  border-radius: 50%;
  width: 100px;
  height: 100px;
  position: fixed;
  right: 25px;
  bottom: 25px;
  transition: all 0.5s;
  &:hover {
    background-color: darken($red, 15);
  }
}

#plus {
  transition: all 0.5s;
  margin-top: 7px;
}

#fa-1, #fa-2, #fa-3 {
  position: fixed;
  background: transparent;
  border: none;
  right: 60px;
  bottom: 57px;
  transition: all 0.5s;
  color: white;

  &:hover {
   tansition-delay: 0s;
   color: lighten($red, 15); 
  }
}

.radial {
  &.open {
    height: 400px;
    width: 400px;
    right: -125px;
    bottom: -125px;

    .fab {
      background-color: darken($red, 15);
      box-shadow: 0px 2px 4px rgba(0,0,0,0.15), 0px 4px 8px rgba(0,0,0,0.2);
    }

    #plus {
      transform: rotateZ(135deg) translate(-1px, 3px);
    }
    #fa-1 {
      transition-delay: 0s;
      transform: translate(-110px, 10px);
    }
    #fa-2 {
      transition-delay: 0.1s;
      transform: translate(-85px, -85px);
    }
    #fa-3 {
      transition-delay: 0.2s;
      transform: translate(10px, -110px);
    }
  }
}

JS

代码语言:javascript
复制
$(document).ready(function(){
  $('.fab').click (function(){
    $('.radial').toggleClass('open');
  });
});

如果这是不可能的开发,一个好的径向浮动按钮也可以工作!

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50614032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档