いくつかの画像にマウスポインタを置いたときにスパンテキストを表示しようとしていますが、これを行う方法を理解できず、すべてがその位置にあり、ここでCSSを表示すると、他のオブジェクトの上にホバーが表示される
(コードペンでshortnedコード、完全なコードを送信)を超えるホバリング時にコードとコードのペンがある https://codepen.io/LCastroN/pen/KqQjaw?editors=1100
HTMLコード
<spam id='A1'class='texto'>texto 1</spam>
<spam id='A2'class='texto'>texto 2</spam>
<spam id='A3'class='texto'>texto 3</spam>
<spam id='A4'class='texto'>texto 4</spam>
<spam id='A5'class='texto'>texto 5</spam>
<spam id='A6'class='texto'>texto 6</spam>
<spam id='A7'class='texto'>texto 7</spam>
<spam id='A8'class='texto'>texto 8</spam>
<spam id='A9'class='texto'>texto 9</spam>
<ul class='circle-container'>
<li><img id='1' src='http://lorempixel.com/100/100/city'></li>
<li><img id='2' src='http://lorempixel.com/100/100/nature'></li>
<li><img id='3' src='http://lorempixel.com/100/100/abstract'></li>
<li><img id='4' src='http://lorempixel.com/100/100/cats'></li>
<li><img id='5' src='http://lorempixel.com/100/100/food'></li>
<li><img id='6' src='http://lorempixel.com/100/100/animals'></li>
<li><img id='7' src='http://lorempixel.com/100/100/business'></li>
<li><img id='8' src='http://lorempixel.com/100/100/people'></li>
<li><img id='9' src='http://lorempixel.com/100/100/city'></li>
<li><img id='10' src='http://lorempixel.com/100/100/nature'></li>
</ul>
SCSSコード
jQueryを使ってあなたはジャバスクリプトがそうする必要がある/// Mixin to put items on a circle
/// [1] - Allows children to be absolutely positioned
/// [2] - Allows the mixin to be used on a list
/// [3] - In case box-sizing: border-box has been enabled
/// [4] - Allows any type of direct children to be targeted
///
/// @param {Integer} $nb-items - Number or items
/// @param {Length} $circle-size - Container size
/// @param {Length} $item-size - Item size
/// @param {String | false} $class-for-IE - Base class name for old IE
@mixin distribute-on-circle(
$nb-items,
$circle-size,
$item-size,
$class-for-IE: false
) {
$half-item: ($item-size/2);
$half-parent: ($circle-size/2);
position: relative; /* 1 */
width: $circle-size;
height: $circle-size;
padding: 0;
border-radius: 50%;
list-style: none; /* 2 */
box-sizing: content-box; /* 3 */
> * { /* 4 */
display: block;
position: absolute;
top: 50%;
left: 50%;
width: $item-size;
height: $item-size;
margin: -$half-item;
}
$angle: (360/$nb-items);
$rot: 0;
@for $i from 1 through $nb-items {
@if not $class-for-IE {
@if $i % 2 == 0{
> :nth-of-type(#{$i}) {
transform: rotate(($rot * 1deg)+18deg) translate($half-parent + 6) rotate(($rot * -1deg) - 18deg);
}}
@else{
> :nth-of-type(#{$i}) {
transform: rotate($rot * 1deg) translate($half-parent) rotate($rot * -1deg);
}}
} @else {
@if $i % 2 == 0{
> .#{$class-for-IE}#{$i} {
// If CSS transforms are not supported
$mt: sin($rot * (pi()/180)+0.1745) * $half-parent+6 - $half-item;
$ml: cos($rot * (pi()/180)+0.1745) * $half-parent+6 - $half-item;
margin: $mt 0 0 $ml;
}}
@else {
> .#{$class-for-IE}#{$i} {
// If CSS transforms are not supported
$mt: sin($rot * pi()/180) * $half-parent - $half-item;
$ml: cos($rot * pi()/180) * $half-parent - $half-item;
margin: $mt 0 0 $ml;
}
}
}
$rot: ($rot + $angle);
}
}
.circle-container {
@include distribute-on-circle(10, 40em, 6em, false);
margin: auto;
padding: 200px 200px 200px 200px;
position: absolute;
//border: solid 5px tomato;
}
.circle-container img {
display: block;
width: 100%;
border-radius: 50%;
filter: grayscale(100%);
&:hover {
filter: grayscale(0);
}
}
.texto{
text-align: center;
display: none;
margin: auto;
position: absolute;
padding: 500px 500px 500px 500px;
}
なぜ「スパム」ですか? – Koralarts
あなたはスパムかスパンを意味しますか?ソリューションにJSを使用してもよろしいですか? – DCR
は、フルサークル内、または個々のサークル画像の中央に表示されるテキストですか? – csum