简体   繁体   English

在Polymer 2中使用CSS mixin覆盖内联样式

[英]Override inline style with a CSS mixin in Polymer 2

Is there a way to override the inline style of a component in Polymer 2 with a CSS mixin ? 有没有办法用CSS mixin覆盖Polymer 2中组件的内联样式

In Polymer 1, I had a similar code as below in my component to do that and it is working fine (see #1 image): 在Polymer 1中,我在组件中有一个类似于以下代码的代码,它工作正常(请参见#1图像):

<style>
    paper-menu-button {
        display: block;

        --paper-menu-button-dropdown: {
            position: relative !important;
            top: auto !important;
            left: auto !important;
            display: block;
        };

        --paper-menu-button-content: {
            max-width: none !important;
            max-height: none !important;
            display: block;
        };
    }
</style>

But with Polymer 2, it is not working anymore (see #2 image). 但是对于Polymer 2,它不再起作用了(请参阅#2图像)。

JS bin for Polymer 2. 聚合物2的JS仓

1. Polymer 1 : CSS: 1.聚合物1: CSS:

聚合物1-CSS结果

Output: 输出:

聚合物1-输出


2. Polymer 2: CSS: 2.聚合物2: CSS:

聚合物2-CSS结果

Output: 输出: 在此处输入图片说明

Thanks! 谢谢!

Add width:100%; 增加width:100%; in --paper-menu-button-dropdown . --paper-menu-button-dropdown

Working JS Bin . 工作JS Bin

Also, notice that I have changed iron-icon.html to iron-icons.html for the arrow icon. 另外,请注意,我已经改变了iron-icon.htmliron-icons.html的箭头图标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM