我可以放一个<style>
吗?在 Aurelia View 的模板内标记?我有一个特定的问题,如果我有 <style>
模板中的标记,我的 aurelia-dialog 没有正确对齐(它 float 到屏幕顶部而不是居中在中间)。一旦我删除 <style>
标签,一切都正确放置。 .css
的正确写法是什么? View /模板的类?
示例:对于我的对话框组件(类似于引导模式),我有一个 dialog.html 和一个 dialog.js 在 dialog.html 中,代码如下所示:
<template>
<style media="screen">
.selectedBorder {
border: 1px solid black;
}
</style>
<ai-dialog>
<ai-dialog-header>
Header
</ai-dialog-header>
<ai-dialog-body>
Sample body information
</ai-dialog-body>
<ai-dialog-footer>
Footer info
</ai-dialog-footer>
</ai-dialog>
</template>
编辑:我想通了。你可以有 <style>
模板内的标签。我的问题是我有一个模板(主屏幕区域)调用另一个模板(弹出对话框)。我只需要移动 <style>
从 dialog.html 到主视图的 html,一切正常。
最佳答案
这可能不是普遍的共识,但我一直在做的是使我所有的客户元素无容器,消除标记膨胀,然后使用 id 属性命名模板内容。例如:
someView.html:
<body>
<avatar-pic containerless></avatar-pic>
</body>
头像图片.html
<template>
<section class="avatar-pic">
....
</section>
</template>
头像图片.css
.avatar-pic {
...styles here
}
关于css - html 模板中的样式标签(在 Aurelia View 中)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37081390/