html - Ionic2 圆形分段按钮

标签 html css angular ionic2

有人知道如何将分段按钮的 css 从方形更改为圆形吗?

enter image description here

我尝试使用普通 css但当 ionic2 尝试转换 segment-activated 上的按钮时,它会变得很奇怪,这是一个 Plunker示例

<ion-segment [(ngModel)]="date" danger>
  <ion-segment-button value="1">
    1
  </ion-segment-button>
  <ion-segment-button value="2">
    2
  </ion-segment-button>
  <ion-segment-button value="3">
    3
  </ion-segment-button>
</ion-segment>

使用普通的 css 我失败了。当你选择另一个按钮时,它会变得很奇怪 enter image description here

最佳答案

找到了一个 hack 来做到这一点。 注意这是一个黑客行为,并且样式不是为此目的。

CSS 解决方案:将其放入您的 .scss 文件

ion-segment-button{
  //max-width: 25px;
  border-style: solid;
}

.segment-button {
  border-style: none;
  border-color: #e62100;
  color: #e62100;
  border-width: thin;
}

.segment-button:first-of-type {
  border-radius: 90px 90px 90px 90px;
  // margin-right: 0px;
  margin-left: 0px;
  line-height: 3.4rem;
  height: 100%;
  width: 100%}
.segment-button:not(:first-of-type) {
  border-radius: 90px 90px 90px 90px;
 // margin-right: 0px;
  margin-left: 20px;
  line-height: 3.4rem;
  height: 100%;
  width: 100%;}
.segment-button:last-of-type {
  border-radius: 90px 90px 90px 90px;
  margin-right: 0px;
  margin-left: 20px;
  line-height: 3.4rem;
  height: 100%;
  width: 100%;}


 .segment-activated{
  background-color: #e62100;
  color: #ffffff;
}

关于html - Ionic2 圆形分段按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38527700/

相关文章:

javascript - 插值 RGB 颜色

html - CSS 动画循环淡入淡出 1-2-3-1-2-3-1-2

angular - 使用 angular2 在同一个路由器 socket 中加载多个组件

angular - 将一个 Observable<string> 和一个 Array<Observable<string>> 组合成一个 Observable<{string, string[]}>

javascript - 延迟加载图像

html - 滚动整个页面而不是仅滚动内部 div

css - 带有CSS的div内的图像垂直对齐

Angular6 尝试使用 DecimalPipe 到自定义管道时出现错误

html - Twitter bootstrap 流体行背景

javascript - 防止在隐藏父项并读取子项的 css 时下载背景图像