1

キャプション付きの画像のグループがあり ( http://www.hongkiat.com/blog/css3-image-captions/から)、それらをクリックして非表示の div をオーバーレイするか、オーバーレイとしての外部ページ (機能する限り、私はどちらにもこだわりません!)。また、各画像を別のページ/divにリンクしたいと思います。私は成功せずに多くのことを試しましたので、多くの助けをいただければ幸いです。画像のコードは次のとおりです(はい、テスト目的で2回表示されます):

<div id="mainwrapper">
  <table>
    <tr>
      <td>
        <div id="box-1" class="box">  
          <img id="image-1" src="img/agent.png"/>  
          <span class="caption full-caption">  
            <h3>Agent Demo</h3>  
            <p>Java Group Project</p>
          </span>  
        </div> 
      </td>

      <td>
        <div id="box-2" class="box">  
          <img id="image-2" src="img/wizardsbook.png"/>  
          <span class="caption full-caption">  
            <h3>The Wizard's Book</h3>  
            <p>Java Game</p>  
          </span>  
        </div> 
      </td>

      <td>
        <div id="box-3" class="box">  
            <img id="image-3" src="img/wizardsbook.png"/>  
            <span class="caption full-caption">  
              <h3>The Wizard's Book</h3>  
              <p>Java Game</p>  
            </span>  
        </div> 
      </td>
    </tr>
  </table>
</div>
4

3 に答える 3

1

コメントの2番目の質問によると、「ポップアップを表示するための簡単なリンクを取得することさえできません。JQueryを初めて使用するので、JQueryにどのようにリンクすればよいですか、スクリプトをどこに配置すればよいですか、どのように実装すればよいですかimg と attr についてはどうですか?」という質問に対して、必要なものがすべて表示されたスクリーンショットを次に示します。

ここに画像の説明を入力

于 2013-05-09T16:44:47.367 に答える
0

私はあなたがやろうとしていることをするあなたのためにフィドルを作りました。関連ページをロードするために使用する画像の一意の値がわからないため、サンプルコードをいくつか提供しました。

働くフィドルはここにあります:
http://jsfiddle.net/acturbo/YVBpj/

JavaScript:

$().ready(function() {

    $("#close").on("click", function(){
        $("#popup").hide();
    });

   // uncomment this line to attach this "showWindow" to all the images
   // then, use $(this) to access the specific image that was clicked

    //$("img").on("click", function(){
    $("#showWindow").on("click", function(){

        // when you switch to images, you can access unique attributes
        // of the clicked image using attr()
        // this will let you load unique pages for each image
        // eg. can use 1 or 2
        // var value1 = $(this).attr( "src" );
        // var value2 = $(this).attr( "id" );
        //$("#popup").load( value1 );

        $("#popup").show();
    });

});

html:

<div id="popup">
    <p>this is hidden until the image is clicked</p>
    <a href="#" id="close">Close Window</a>
</div>    

<a href="#" id="showWindow">Show Window - mimic an image click</p>

<div id="mainwrapper">
  <table>
    <tr>
      <td>
        <div id="box-1" class="box">  
          <img id="image-1" src="img/agent.png"/>  
          <span class="caption full-caption">  
            <h3>Agent Demo</h3>  
            <p>Java Group Project</p>
          </span>  
        </div> 
      </td>

      <td>
        <div id="box-2" class="box">  
          <img id="image-2" src="img/wizardsbook.png"/>  
          <span class="caption full-caption">  
            <h3>The Wizard's Book</h3>  
            <p>Java Game</p>  
          </span>  
        </div> 
      </td>

      <td>
        <div id="box-3" class="box">  
            <img id="image-3" src="img/wizardsbook.png"/>  
            <span class="caption full-caption">  
              <h3>The Wizard's Book</h3>  
              <p>Java Game</p>  
            </span>  
        </div> 
      </td>
    </tr>
  </table>
</div>

CSS

#popup{
    top: 10px;
    left: 10px;
    width: 300px;
    height: 100px;
    position: absolute;
    background: red;
    display: none;
}
于 2013-05-07T20:11:26.593 に答える
0

それはCSSだけで簡単です。

このフィドルをよく見てください: http://jsfiddle.net/VgLVq/

div をクリック可能にするには、目的<a>の URL を含むタグで囲むだけです。

次に、.boxposition: relative彼のすべての子供を にしposition: absoluteます。セレクターを使用しました.box>*

次に、この CSS を追加.captiondisplay:noneて、ホバーを検出します。

a:hover .caption{
    display:block;
}
于 2013-05-07T20:02:28.643 に答える