gpt4 book ai didi

css - 聚合物中的自定义样式与共享样式

转载 作者:技术小花猫 更新时间:2023-10-29 11:06:44 26 4
gpt4 key购买 nike

Polymer 支持 <style is="custom-style">它允许您定义仅适用于元素的样式,例如影子 DOM。

Polymer 还支持 <dom-module id="shared-styles">它允许您打包一组可以导入到元素定义中的样式声明。

因此,它们的重点似乎都是让您可以设计聚合物元素的样式。你为什么要用一个而不是另一个?这些用例似乎有很大的重叠。

额外的混淆:shared-styles可以导入custom-style .你为什么要这样做?为什么不呢?

最佳答案

A <dom-module id="my-shared-styles">声明一个可重用的样式模块帽子,您可以将其导入元素或 <style is="custom-style">标签。

在自定义元素中使用

<dom-module id="my-element>
<template>
<style include="my-shared-styles"></style>
...
</template>
</dom-module>

或在<style>自定义元素外的标记(例如在 <head> 中)

<head>
<style is="custom-style" include="my-shared-styles"></style>
</head>

<style is="custom-style">仅当您想在不在 <dom-module> 内的样式元素中使用 Polymer CSS 功能(CSS 变量和混合)时才需要.里面<dom-module>只是 <style>就够了。

关于css - 聚合物中的自定义样式与共享样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36224425/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com