css - html 模板中的样式标签(在 Aurelia View 中)?

标签 css templates view styles aurelia

我可以放一个<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/

相关文章:

javascript - jQuery 隐藏所有而不是只隐藏不活动

html - 在 golang HTML 模板中切换或 if/elseif/else

sql - Mysql - 我可以有一个 View ,它是表的内存图像

swift - 快速在uicollectionview的单元格中添加阴影

Jquery 幻灯片可以在本地运行,但不能在线运行

jquery - 为圆形 slider 中的图像赋予 Angular

c++ - 避免专用模板中的代码重复

c++ - 成员函数检测的递归type_traits

android - getHeight() 与 getLayoutParams().height

html - 我怎样才能只选择第一个不是脚本标签的普通兄弟?