0

私のページの設定方法はかなりしっかりしています。写真のギャラリーがあります。マウスを小さなアイコンの1つの上に置くと、大きなアイコンがポップアップ表示され、ページ上の最大の画像がその画像に変わります。これはすべて、インラインCSSを介してonMouseOverイベントとonMouseOffイベントを使用して行いました。

ただし、テキストボックスでも同じことをしたいと思います。たとえば、犬の写真にカーソルを合わせると、ページの下部にある「dogdiv」という名前のdiv内のテキストが、idtextareaのテキストボックスに表示されるようにします。JavaScript(JS)でこれを行う方法は知っていますが、使用しているサーバーの制限により、これはオプションではなくなりました。ストレートCSSである必要があります。

私はそれが可能であることを知っています、私はただ方法を見つけることができないようです。これを機能させるために私が何をする必要があるか教えてもらえますか?

<html> 
<head>
<title>Text/Photo Swap Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
body {background: url('gradient.png');}

#gallery {position: relative; }
#gallery ul {list-style-type: none;
    width: 300px; }
#gallery li { display: inline; 
     float: left;
     padding: 5px; }
#gallery img {border-style: solid: 10px; border-color: #333; }
#gallery a { text-decoration: none;
             font-style: none;  
             color: #333; }

#mainPicture {
    float: right;
        }

.popOut
{
    cursor: default;
    list-style: none;
}
.popOut a
{
    cursor: default;
}
.popOut a .preview
{
    display: none;
}
.popOut a:hover .preview
{
    display: block;
    position: absolute;
    top: -33px;
    left: -45px;
    z-index: 1;
}
.popOut img
{
    background: #ebf0f3;
    border-color: #ebf0f3;
    border-style: solid;
    border-width: 1px;
    color: inherit;
    vertical-align: top;
    width: 100px;
    height: 75px;
}
.popOut li
{
    background: #ebf0f3;
    border-color: #CCCCCC;
    border-style: solid;
    border-width: 0px;
    color: inherit;
    display: inline;
    float: left;
    margin: 3px;
    padding: 2px;
    position: relative;
}
.popOut .preview
{
    border-color: #000;
    width: 200px;
    height: 150px;
}
.popOut p
{
    text-align: center;
}

#textarea
{
    background-color: #ebf0f3;
}

div.hideText
{
display:none;
}


</style>
</head>

<body>
<div class="mainPicture"><img id="awesome" src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/awesome.png" height="300" width="400" alt="" name="Awesome2"><!--style="position:relative; left:600px; top:326px;"--></div>

<td width="1000" rowdiv="3">
<div id="gallery">
    <ul class="popOut">
        <li>
            <a href="" onMouseOver="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/dog.jpg';" onMouseOut="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/dog.jpg';">
                <img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/dog.jpg" width="100" height="75" alt="dog"><img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/dog.jpg" width="100" height="75" alt="dog" class="preview"> 
            </a>
        </li>
        <li>
            <a href="" onMouseOver="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/cat.jpg';" onMouseOut="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/cat.jpg';">
                <img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/cat.jpg" width="100" height="75" alt="cat"><img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/cat.jpg" width="100" height="75" alt="cat" class="preview"> 
            </a>
        </li>
        <li>
            <a href="" onMouseOver="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/parrot.jpg';" onMouseOut="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/parrot.jpg';">
                <img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/parrot.jpg" width="100" height="75" alt="parrot"><img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/parrot.jpg" width="100" height="75" alt="parrot" class="preview"> 
            </a>
        </li>
        <li>
            <a href="" onMouseOver="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/lizard.jpg';" onMouseOut="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/lizard.jpg';">
                <img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/lizard.jpg" width="100" height="75" alt="lizard"><img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/lizard.jpg" width="100" height="75" alt="lizard" class="preview"> 
            </a>
        </li>
        <li>
            <a href="" onMouseOver="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/horse.jpg';" onMouseOut="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/horse.jpg';">
                <img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/horse.jpg" width="100" height="75" alt="horse"><img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/horse.jpg" width="100" height="75" alt="horse" class="preview"> 
            </a>
        </li>
        <li>
            <a href="" onMouseOver="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/chicken.jpg';" onMouseOut="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/chicken.jpg';">
                <img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/chicken.jpg" width="100" height="75" alt="chicken"><img src="http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/chicken.jpg" width="100" height="75" alt="chicken" class="preview"> 
            </a>
        </li>
        <li onMouseOver="textarea.textarea2='chickendiv'">
            <a href="" onMouseOver="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/awesome.png';" onMouseOut="document.Awesome2.src='http://ctd-dev.jdc.ao.dcn/sites/ctd-dev.jdc.ao.dcn/files/pictures/awesome.png';">
                <p>Default Image</p>
            </a>
        </li>
    </ul>

    <div id="textarea" style="height:600px;width:320px;font:14px;font:14px/26px Arial, Helvetica, sans-serif;overflow:scroll; position:relative;
    top:12px;"><div id="textarea2"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi pulvinar lectus non lectus auctor egestas. Donec at nunc neque. Morbi ornare condimentum lobortis. Nam vehicula urna ac mauris pharetra rutrum. Duis et arcu eget sapien interdum porttitor ut et tortor. Maecenas ultricies dignissim pretium. Integer quis enim metus. Sed enim lacus, eleifend eu euismod volutpat, blandit eu sem. Vestibulum varius purus ut est accumsan pellentesque. Donec quis enim id lectus sollicitudin suscipit at volutpat augue. Curabitur et metus purus. Fusce luctus nunc vitae sapien pharetra id accumsan lectus malesuada.</p></div>
    </div>
    </div>
</td>

<div id="dogdiv" class="hideText"><p>The domestic dog (Canis lupus familiaris), is a subspecies of the gray wolf (Canis lupus), a member of the Canidae family of the mammilian order Carnivora. The term domestic dog is generally used for both domesticated and feral varieties. The dog may have been the first animal to be domesticated, and has been the most widely kept working, hunting, and companion animal in human history. The word dog may also mean the male of a canine species, as opposed to the word bitch for the female of the species.</p>
</div>
<div id="catdiv" class="hideText"><p>The domestic cat (Felis catus or Felis silvestris catus) is a small, usually furry, domesticated, carnivorous mammal. It is often called the housecat when kept as an indoor pet, or simply the cat when there is no need to distinguish it from other felids and felines. Cats are valued by humans for companionship and ability to hunt vermin and household pests. They are primarily nocturnal.</p>
</div>
<div id="parrotdiv" class="hideText"><p>Parrots, also known as psittacines are birds of the roughly 372 species in 86 genera that make up the order Psittaciformes, found in most tropical and subtropical regions. The order is subdivided into three superfamilies: the Psittacoidea  parrots), the Cacatuoidea (cockatoos) and the Strigopoidea (New Zealand parrots). Parrots have a generally pantropical distribution with several species inhabiting temperate regions in the Southern Hemisphere as well. The greatest diversity of parrots is found in South America and Australasia.</p>
</div>
<div id="lizarddiv" class="hideText"><p>Lizards are a widespread group of squamate reptiles, with more than 5600 species , ranging across all continents except Antarctica as well as most oceanic island chains. The group, traditionally recognized as the suborder Lacertilia, is defined as all extant members of the Lepidosauria (reptiles with overlapping scales), which are neither sphenodonts (i.e., tuatara) nor snakes ? they form an evolutionary grade. While the snakes are recognized as falling phylogenetically within the Toxicofera clade from which they evolved, the Sphenodonts are the sister group to the Squamates, the larger monophyletic group, which includes both the lizards and the snakes.</p>
</div>
<div id="horsediv" class="hideText"><p>The horse (Equus ferus caballus) is one of two extant subspecies of Equus ferus, or the wild horse. It is an odd-toed ungulate mammal belonging to the taxonomic family Equidae. The horse has evolved over the past 45 to 55 million years from a small multi-toed creature into the large, single-toed animal of today. Humans began to domesticate horses around 4000 BC, and their domestication is believed to have been widespread by 3000 BC. Horses in the subspecies caballus are domesticated, although some domesticated populations live in the wild as feral horses. These feral populations are not true wild horses, as this term is used to describe horses that have never been domesticated, such as the endangered Przewalski Horse, a separate subspecies, and the only remaining true wild horse. There is an extensive, specialized vocabulary used to describe equine-related concepts, covering everything from anatomy to life stages, size, colors, markings, breeds, locomotion, and behavior.</p>
</div>
<div id="chickendiv" class="hideText"><p>The chicken (Gallus gallus domesticus) is a domesticated fowl, a subspecies of the Red Junglefowl. As one of the most common and widespread domestic animals, and with a population of more than 24 billion in 2003, there are more chickens in the world than any other species of bird. Humans keep chickens primarily as a source of food, consuming both their meat and their eggs.</p>
</div>
</body>
</html>
4

2 に答える 2

1

これをドキュメント準備機能に貼り付けます

$("img").bind("mouseover", function(){
   var key = $(this).attr("alt");
   $("#textarea").text($("#" + key + "div").text());
}).bind("mouseout",function(){
   $("#textarea").text("");
});

これにより、ページ上のすべての画像にイベントハンドラーがアタッチされます。$( "#popOut> img")は、ポップアウトリスト内の画像にのみタグを付けます。

さて、それをひどくしなければならないという追加の制約を回避するために:

JQuery:

<img … 
    onmouseover='$("#textarea").text($("#" + $(this).attr("alt") + "div").text());'
    onmouseout='$("#textarea").text("");'
>

DOM:

<img … 
    onmouseover='document.getElementById("textarea").innerText = document.getElementById( this.alt + "div").innerText;'
    onmouseout='document.getElementById("textarea").innerText = "";'
>
于 2012-05-14T18:54:25.000 に答える
1

これはあなたが必要なものです

<ul id="thumbs">

  <li>
    <div class="large-thumb"><img src="large-thumb.jpg" /></div>
    <div class="small-thumb"><img src="small-thumb.jpg /></div>
  </li>

  <li>
    <div class="large-thumb"><img src="large-thumb.jpg" /></div>
    <div class="small-thumb"><img src="small-thumb.jpg /></div>
  </li>

</ul>

display: none;クラスに適用したいCSSを使用して、.large-thumb以下のcssを参照してください。

#thumbs {
  float: left;
  width: 100%;
  padding: 20px 0;}

#thumbs li {
  float: left;
  display: inline;
  margin-right: 10px;}

#thumbs li .large-thumb { display: none; /*Hide the large thumb*/}

#thumbs li:hover .large-thumb { display: block; /*Show on Hover*/}

残りのCSSはあなたに任せますが、liあなたがやろうとしていることを達成するには、相対的な位置に配置してから、大きな親指を絶対に配置する必要があります。

お役に立てれば :-)

于 2012-05-14T16:53:05.447 に答える