微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

样式不适用于嵌套组件

如何解决样式不适用于嵌套组件

我有两个Web组件(#include <iostream> #include <fstream> #include <vector> using namespace std; void read_values(std::string_view line,std::vector<double> &values); void calculations(int,int,int); int main() { string inputFile,outputFile; cout << "Enter the name of your input file: "; cin >> inputFile; cout << "Enter the name of your output file: "; cin >> outputFile; ifstream myfile(inputFile); if (!myfile.is_open()) { cout << "unable to open file"; return -1; } std::string line; std::vector<double> values; while (std::getline(myfile,line,'\n')) { read_values(line,values); std::cout << values.size(); } return 0; } void read_values(std::string_view line,std::vector<double> &values) { while (!line.empty()) { const std::string_view::size_type pos_space{line.find(' ')}; try { values.push_back(std::stod(std::string(line.substr(0,pos_space)))); } catch (const std::invalid_argument &ex) { std::cout << ex.what() << std::endl; return; } line.remove_prefix(pos_space + 1); } } my-section)。

my-blockmy-section内,但是边框并不适用(请查看边框红色,这是一条没有宽度的垂直线)。

当我在可编辑的div中编写时,它显示my-block Web组件的高度,但是即使我写了几行它也始终是相同的(21px)。由于某些原因,父级(my-block)将子级组件(my-section)视为一行。为什么?

Demo

my-block

解决方法

来自:

static get styles() {
  return css`
    * {
      margin: 20px;
    }
  `;
}

收件人:

static get styles() {
  return css`
    * {
      margin: 20px;
      display: block;
    }
  `;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。