Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使图像位于背景色之前?_Html_Css_Image_Background - Fatal编程技术网

Html 如何使图像位于背景色之前?

Html 如何使图像位于背景色之前?,html,css,image,background,Html,Css,Image,Background,我有两种背景色。一部分是灰色的,另一部分是白色的。背景的灰色部分只覆盖了背景的一小部分,其余部分被白色覆盖。现在我想添加一个图像作为我的“徽标”,它应该位于背景的灰色部分。图像当前位于两个背景之下,我只是不知道如何使图像位于背景之下 <style type="text/css"> #grey-bg { position: fixed; top: 0px; left: 0px; width: 100%; heigh

我有两种背景色。一部分是灰色的,另一部分是白色的。背景的灰色部分只覆盖了背景的一小部分,其余部分被白色覆盖。现在我想添加一个图像作为我的“徽标”,它应该位于背景的灰色部分。图像当前位于两个背景之下,我只是不知道如何使图像位于背景之下

<style type="text/css">      
  #grey-bg {
    position: fixed;
      top: 0px;
      left: 0px;
      width: 100%;
      height: 25%;
      background-color: grey;
  }
  body
  {
    background-color:white;
  }   
</style>
</head>

<body>
<div id="grey-bg">
<body bgcolor="grey">
</div>
<center><img    src="http://img2.wikia.nocookie.net/__cb20110818145752/prototype/images/thumb/6/64/Prototype_-_Logo.png/660px-Prototype_-_Logo.png alt="Prototype"></center>
我希望这是可以理解的。我对这一点还很陌生,并试图尽可能地说清楚。
任何帮助都将不胜感激

只需将图像元素移动到带有灰色背景的div中即可

<div id="grey-bg">    
  <center><img src="http://img2.wikia.nocookie.net/__cb20110818145752/prototype/images/thumb/6/64/Prototype_-_Logo.png/660px-Prototype_-_Logo.png" alt="Prototype" /></center>
</div>
小提琴:


你也应该避免使用中间标签,而是使用CSS。

是的,先学习基本知识:你现在有两个身体标签等。我查看了你的个人资料。你应该知道这一点。你知道答案吗你知道CSS3可以在一个元素上有多个背景。没问题。如果有帮助,请接受我的回答:-