小编And*_*ich的帖子

CSS Flex Box布局:全宽行和列

各位程序员大家好!

我有一个简单的盒子布局,我很乐意使用flexbox实现,但我简直无法理解.它应该看起来像这个图像.

在此输入图像描述

所以基本上是一行和两列,其中行被固定在高度上,比如100px,但是在一个容器中.到目前为止我的代码是:

#productShowcaseContainer {
  display: inline-flex;
  flex-flow: row wrap;
  height: 600px;
  width: 580px;
  background-color: rgb(240, 240, 240);
}

#productShowcaseTitle {
  display: inline-block;
  height: 100px;
  width: 100%;
  background-color: rgb(200, 200, 200);
}

#productShowcaseDetail {
  flex: 3;
  background-color: red;
}

#productShowcaseThumbnailContainer {
  flex: 2;
  background-color: blue;
}
Run Code Online (Sandbox Code Playgroud)
<div id="productShowcaseContainer">
  <div id="productShowcaseTitle"></div>
  <div id="productShowcaseDetail"></div>
  <div id="productShowcaseThumbnailContainer"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

我知道这可以通过多种方式实现,但我更喜欢使用CSS Flex.

css layout flexbox

39
推荐指数
2
解决办法
14万
查看次数

C++ 中的模板化 is_in() 函数(检查数组是否包含字符串)

我想做以下事情:

\n
std::string b = "b";\nis_in("a", { "a", "b", "c" });\nis_in("d", { "a", "b", "c" });\nis_in(b, { "a", "b", "c" }); // fails\nis_in(b, std::array{ "a", "b", "c" });\n
Run Code Online (Sandbox Code Playgroud)\n

使用模板

\n
template<typename Element, typename Container>\nbool is_in(const Element& e, const Container& c)\n{\n    // https://stackoverflow.com/questions/20303821/how-to-check-if-string-is-in-array-of-strings\n    return std::find(std::begin(c), std::end(c), e) != std::end(c);\n}\n\ntemplate<typename Element>\nbool is_in(Element e, std::initializer_list<Element> l)\n{\n    // return std::find(std::begin(l), std::end(l), e) != std::end(l);\n    return is_in<Element, std::initializer_list<Element>>(e, l);\n}\n
Run Code Online (Sandbox Code Playgroud)\n

但我收到以下错误(使用 GCC 9.3.0):

\n
no matching function for call to \xe2\x80\x98is_in(std::string&, <brace-enclosed initializer list>)\xe2\x80\x99\n …
Run Code Online (Sandbox Code Playgroud)

c++ arrays string gcc templates

3
推荐指数
1
解决办法
528
查看次数

标签 统计

arrays ×1

c++ ×1

css ×1

flexbox ×1

gcc ×1

layout ×1

string ×1

templates ×1