CSS:将标题中的渐变背景与图像组合作为徽标

时间:2016-12-21 14:56:07

标签: css image background header gradient

我正在尝试使用此渐变:

iterator_of_iterator_version_2.cpp:9:15: error: expected ‘=’ before ‘<’ token
 using Iterator<T> = typename T::iterator;
               ^
iterator_of_iterator_version_2.cpp:9:15: error: expected type-specifier before ‘<’ token
iterator_of_iterator_version_2.cpp:12:8: error: ‘Iterator’ was not declared in this scope
 vector<Iterator<C>> find_all(C& c, V v)
        ^
iterator_of_iterator_version_2.cpp:12:17: error: template argument 1 is invalid
 vector<Iterator<C>> find_all(C& c, V v)
                 ^
iterator_of_iterator_version_2.cpp:12:17: error: template argument 2 is invalid
iterator_of_iterator_version_2.cpp:12:18: error: expected unqualified-id before ‘>’ token
 vector<Iterator<C>> find_all(C& c, V v)
                  ^
iterator_of_iterator_version_2.cpp: In function ‘void test()’:
iterator_of_iterator_version_2.cpp:24:30: error: ‘find_all’ was not declared in this scope
  for (auto p : find_all(m,'a'))
                              ^
iterator_of_iterator_version_2.cpp:29:31: error: ‘find_all’ was not declared in this scope
  for (auto p : find_all(ld,1.1))
                               ^
iterator_of_iterator_version_2.cpp:33:35: error: ‘find_all’ was not declared in this scope
  for (auto p : find_all(vs,"green"))
                                   ^
iterator_of_iterator_version_2.cpp:36:35: error: ‘find_all’ was not declared in this scope
  for (auto p : find_all(vs,"green"))
                                   ^

和这张图片:

background: rgba(0, 0, 0, 0) linear-gradient(45deg, rgba(204, 202, 204, 1) 0%, rgba(204, 202, 204, 1) 11%, rgba(252, 252, 252, 1) 45%, rgba(252, 252, 252, 1) 53%, rgba(214, 212, 214, 1) 81%, rgba(204, 202, 204, 1) 88%) repeat scroll 0 0;

组合在一起,但是我没有这样做,因为它既显示了渐变,也显示了图像,而不是同时显示两者。我对CSS没有多大帮助,因此我已经用尽了更多的想法来实现它。

1 个答案:

答案 0 :(得分:0)

您可以将渐变添加为伪元素,如下所示:

&#13;
&#13;
div {
  height: 200px;
  width: 200px;
  background-image: url('http://placehold.it/350x350');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: 10% 25%;
  position: relative;
}
div:before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: linear-gradient(45deg, rgba(204, 202, 204, 1) 0%, rgba(204, 202, 204, 1) 11%, rgba(252, 252, 252, 1) 45%, rgba(252, 252, 252, 1) 53%, rgba(214, 212, 214, 1) 81%, rgba(204, 202, 204, 1) 88%);
  opacity: .5;
}
&#13;
<div></div>
&#13;
&#13;
&#13;