【问题标题】:How to style primeng spiltbutton look like bootstrap button如何设置primeng拆分按钮看起来像引导按钮
【发布时间】:2020-12-06 07:26:39
【问题描述】:

您好,在下面的 stackblitz 链接中,我有两个控件, 一个是primeng splitbutton,另一个是bootstrap button。

https://stackblitz.com/edit/angular6-primeng-hlxeod?file=src/app/app.component.html

我无法自定义 splitbutton 的宽度和颜色以使其看起来像 bootstrap button 。 请分享任何建议

我已经尝试了 styleClass 和样式内联,但它没有得到反映。

在我的实际应用程序中,我有许多其他控件,因此无法通过类来仅控制特定的拆分按钮

【问题讨论】:

    标签: javascript css typescript angular-ui-bootstrap primeng


    【解决方案1】:

    .btn {
      display: inline-block;
      font-weight: 400;
      text-align: center;
      white-space: nowrap;
      vertical-align: middle;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      border: 1px solid transparent;
      padding: 0.375rem 0.75rem;
      font-size: 1rem;
      line-height: 1.5;
      border-radius: 0.25rem;
      transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    }
    
    .btn:hover, .btn:focus {
      text-decoration: none;
    }
    
    .btn:focus, .btn.focus {
      outline: 0;
      box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    }
    
    .btn.disabled, .btn:disabled {
      opacity: 0.65;
    }
    
    .btn:not(:disabled):not(.disabled) {
      cursor: pointer;
    }
    
    .btn:not(:disabled):not(.disabled):active, .btn:not(:disabled):not(.disabled).active {
      background-image: none;
    }
    
    .btn-primary {
      color: #fff;
      background-color: #007bff;
      border-color: #007bff;
    }
    
    .btn-primary:hover {
      color: #fff;
      background-color: #0069d9;
      border-color: #0062cc;
    }
    
    .btn-primary:focus, .btn-primary.focus {
      box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
    }
    
    .btn-primary.disabled, .btn-primary:disabled {
      color: #fff;
      background-color: #007bff;
      border-color: #007bff;
    }
    
    .btn-primary:not(:disabled):not(.disabled):active, .btn-primary:not(:disabled):not(.disabled).active,
    .show > .btn-primary.dropdown-toggle {
      color: #fff;
      background-color: #0062cc;
      border-color: #005cbf;
    }
    
    .btn-primary:not(:disabled):not(.disabled):active:focus, .btn-primary:not(:disabled):not(.disabled).active:focus,
    .show > .btn-primary.dropdown-toggle:focus {
      box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
    }
    <button class='btn btn-primary'>here</button>

    已应用引导程序 :focus 和 :hover 等

    【讨论】:

    【解决方案2】:

    所以我想通了,当我将 css 放入全局 styles.scss 时,它能够实现和更改 css。您可以使用 styleClass 或 class 使其具体化,因为在dependenices.json 中,样式应该位于primeng css 类之后,这就是它可以覆盖的原因

    【讨论】:

      猜你喜欢
      • 2019-06-01
      • 2018-05-29
      • 2011-07-28
      • 2015-01-11
      • 1970-01-01
      • 2014-05-29
      • 1970-01-01
      • 2010-09-05
      相关资源
      最近更新 更多