我试图使用选择器设置width和height在WebComponent中:host,但大小不会改变.以下是组件的模板:
<template>
<style>
:host {
width: 100px;
height: 100px;
background-color: rebeccapurple;
}
</style>
<h1>Content</h1>
</template>
Run Code Online (Sandbox Code Playgroud)
我需要做的是添加div一个容器并设置它的大小
<template>
<style>
div {
width: 100px;
height: 100px;
background-color: rebeccapurple;
}
</style>
<div>
<h1>Content</h1>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我想明白为什么这是不可能的以及它的原因.或者,如果有更好的方法来解决这个问题.
这是它的一个JSBin:http://jsbin.com/gesovagapi/edit?html,css,js,output