私はコードを学習するための最初のステップを行っています。私はCodeacademyでいくつかのコースを作ったので、私はWordPressの子供のテーマを構築しながら、経験から学び続けることにしました。ワードプレスを使用して文字をホバーしながら画像フィールドを表示
私はタイトルのあるホームページを途中で作っています。アイデアは、手紙の中にホバーを置くと、イメージが表示されるということです。このように、それぞれの文字には異なるイメージを表示することができます。
は、私は、次のコードを作っ:PHP:
<?php get_header(); ?>
<div class="imghome imghome1"><?php the_field("image"); ?></div>
<div class="imghome imghome2"><?php the_field("image_2"); ?></div>
<div class="imghome imghome3"><?php the_field("image_3"); ?></div>
<div class="imghome imghome4"><?php the_field("image_4"); ?></div>
<div class="imghome imghome5"><?php the_field("image_5"); ?></div>
<div class="imghome imghome6"><?php the_field("image_6"); ?></div>
<div class="imghome imghome7"><?php the_field("image_7"); ?></div>
<div class="imghome imghome8"><?php the_field("image_8"); ?></div>
<div class="imghome imghome9"><?php the_field("image_9"); ?></div>
<div class="imghome imghome10"><?php the_field("image_10"); ?></div>
</div><!-- .content-area -->
<div class="helloworld ">
<span class="word1" content="A">A</span>
<span class="word2" content="B">B</span>
<span class="word3" content="C">C</span>
<span class="word4" content="D">D</span>
<span class="word5" content="E">E</span>
<span class="namespace word6" content="F">F</span>
<span class="word7" content="G">G</span>
<span class="word8" content="H">H</span>
<span class="word9" content="I">I</span>
<span class="word10" content="I">I</span>
<span class="word11" content="J">J</span>
</div>
</div><!-- .content-area -->
<?php get_footer(); ?>
CSS:あなたがクラスを持つ要素でホバーを加えた場合、私の考えはある。この例では
.helloworld {
font-family: pcablack;
font-size: 21px;
word-spacing: -16px;
text-align: center;
margin-top: 40vh;
position: inherit;
z-index: 10000;
}
.namespace {
margin-left: 12px;
}
.imghome1 {
display: none;
}
.imghome2 {
display: none;
}
.imghome3 {
display: none;
}
.imghome4 {
display: none;
}
.imghome5 {
display: none;
}
.imghome6 {
display: none;
}
.imghome7 {
display: none;
}
.imghome8 {
display: none;
}
.imghome9 {
display: none;
}
.imghome10 {
display: none;
}
.word1:hover .imghome1 {
display: block;
cursor: pointer;
}
「単語1クラス "imghome1"の画像が表示されます。しかし、それは動作しません。
私もこれをtryiedが、成功せず:
div .word1:hover div .imghome1 {
display: block;
cursor: pointer;
}
div .helloworld span .word1:hover .imghome1 {
display: block;
cursor: pointer;
}
あなたは、いくつかの提案を持っていますか?
何をして動作しませんか? –
.word1でホバーすると、.imghome1は表示されません。これは、私がこのコードdivで間違っていることです.helloworldスパン.word1:ホバー.imghome1 { display:block; カーソル:ポインタ; } –
を試してみてください.helloworld:hover {display:none;} –