doujin8673 2011-06-07 09:18
浏览 44

背景切换器?

I’m trying to create a background switcher, but I’m unsure as to what approach I should take. I’m trying to avoid multiple style sheets, so should I maybe use uri segments and a redirect to referrer? or use a form for each item and make the anchor for each thumbnail the submit button sending a hidden id to php?

Also I’m aiming to store some meta data for each background in a db, so I could pull information such as the artist or the name of the background from the db.

I’m just stuck, can someone give me a nudge? Please and thank you [:

  • 写回答

1条回答 默认 最新

  • dongxie1907 2011-06-07 09:53
    关注

    Here's what I used.

    <?php
            $backgrounds = array();
            foreach(scandir('images/') as $file)
              if(strpos($file, '.png')||strpos($file, '.jpg')||strpos($file, '.jpeg'))
                array_push($backgrounds, $file);
            shuffle($backgrounds);
    ?>
    <img id="bg" src="images/<?php echo $backgrounds[0]; ?>" />
    

    And the CSS:

    #bg{
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: -1;
      position: absolute;
    }
    

    This creates a scaling background which is completely random among all the images in the "images" folder.

    I'm off to school, so I don't have time to modify it for your purposes, but maybe this will give you the nudge you've been looking for.

    评论

报告相同问题?

悬赏问题

  • ¥15 vue3加ant-design-vue无法渲染出页面
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序