将图像库放在背景图像上

时间:2018-03-02 00:02:42

标签: html css image background

在我的主页上,我有一张背景图片,我希望用中间放置的图片库(4张图片)覆盖该背景图片。我附上了screen shot给人们一个想法。

由于

2 个答案:

答案 0 :(得分:0)

像这样:



document.getElementById('g1').onclick = function() {
  document.getElementById('bigImage').innerHTML = '<img src="http://www.kurzweilai.net/images/Naam-Limits-of-Earth-Part1-001-earth-600x600.jpg" style="height: 600px; width: 600px;">';
  document.getElementById('g1').innerHTML = '<img src="http://www.spitzer.caltech.edu/uploaded_files/images/0009/6502/ssc2013-07b_Ti.jpg" style="height: 60px; width: 60px;">';
};
&#13;
#bigImage{
  width: 600px;
  height: 600px;
}
#gallery {
  width: 60px;
  height: 60px;
  z-index: 99999;
}
&#13;
<div>
  <div id = "bigImage">
    <img src="http://www.spitzer.caltech.edu/uploaded_files/images/0009/6502/ssc2013-07b_Ti.jpg" style="height: 600px; width: 600px;">
  </div>
  <div id = "gallery">
    <div id = "g1">
      <img src="http://www.kurzweilai.net/images/Naam-Limits-of-Earth-Part1-001-earth-600x600.jpg" style="height: 60px; width: 60px;">
    </div>
  </div>

</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

或者像这样,通过使用位置属性......

#bigImage{
  width: 600px;
  height: 600px;
  background-image: url("http://www.spitzer.caltech.edu/uploaded_files/images/0009/6502/ssc2013-07b_Ti.jpg");
}
#gallery {
  width: 60px;
  height: 60px;
  z-index: 99999;
  position: absolute;
  bottom: 30px;
  right: 30px;
}
<div id = "bigImage">
  <div id = "gallery">
      <img src="http://www.kurzweilai.net/images/Naam-Limits-of-Earth-Part1-001-earth-600x600.jpg" style="height: 60px; width: 60px;">
    </div>
</div>