gpt4 book ai didi

html - HTML、CSS 中的数据语句

转载 作者:行者123 更新时间:2023-11-28 17:04:51 24 4
gpt4 key购买 nike

我想在将鼠标悬停在图像上后执行此操作,显示属性 data-sentence 中的文本(在图片下方)。我没有看到这样的属性。谁能告诉我如何做这样的事情?

HTML:

<li>
<input id="checkbox_yoda" type="checkbox" name="character" value="light_side">
<label for="checkbox_yoda" data-sentence="Force is strong in you">Yoda</label>
</li>

CSS:

input[type=checkbox] {
display: none;
}

label[for=checkbox_yoda] {
content: url(../images/yoda.png);
}

最佳答案

你可以这样做

input[type=checkbox] {
display: none;
}

label[for=checkbox_yoda] {

}

.text-center {
text-align: center;
}

[data-science] {
position: relative;
}

[data-science]::before,
[data-science]::after {
text-transform: none;
font-size: .9em;
line-height: 1;
user-select: none;
pointer-events: none;
position: absolute;
display: none;
opacity: 0;
}
[data-science]::before {
content: '';
border: 5px solid transparent;
z-index: 1001;
}
[data-science]::after {
content: attr(data-science);
font-family: Helvetica, sans-serif;
text-align: center;
min-width: 3em;
max-width: 21em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: 1ch 1.5ch;
border-radius: .3ch;
box-shadow: 0 1em 2em -.5em rgba(0, 0, 0, 0.35);
background: #333;
color: #fff;
z-index: 1000;
}

[data-science]:hover::before,
[data-science]:hover::after {
display: block;
}

[data-science='']::before,
[data-science='']::after {
display: none !important;
}

/* FLOW: UP */
[data-science]:not([flow])::before,
[data-science][flow^="up"]::before {
bottom: 100%;
border-bottom-width: 0;
border-top-color: #333;
}
[data-science]:not([flow])::after,
[data-science][flow^="up"]::after {
bottom: calc(100% + 5px);
}
[data-science]:not([flow])::before,
[data-science]:not([flow])::after,
[data-science][flow^="up"]::before,
[data-science][flow^="up"]::after {
left: 50%;
transform: translate(-50%, -.5em);
}

/* FLOW: DOWN */
[data-science][flow^="down"]::before {
top: 100%;
border-top-width: 0;
border-bottom-color: #333;
}
[data-science][flow^="down"]::after {
top: calc(100% + 5px);
}
[data-science][flow^="down"]::before,
[data-science][flow^="down"]::after {
left: 50%;
transform: translate(-50%, .5em);
}

/* FLOW: LEFT */
[data-science][flow^="left"]::before {
top: 50%;
border-right-width: 0;
border-left-color: #333;
left: calc(0em - 5px);
transform: translate(-.5em, -50%);
}
[data-science][flow^="left"]::after {
top: 50%;
right: calc(100% + 5px);
transform: translate(-.5em, -50%);
}

/* FLOW: RIGHT */
[data-science][flow^="right"]::before {
top: 50%;
border-left-width: 0;
border-right-color: #333;
right: calc(0em - 5px);
transform: translate(.5em, -50%);
}
[data-science][flow^="right"]::after {
top: 50%;
left: calc(100% + 5px);
transform: translate(.5em, -50%);
}

/* KEYFRAMES */
@keyframes data-sciences-vert {
to {
opacity: .9;
transform: translate(-50%, 0);
}
}

@keyframes data-sciences-horz {
to {
opacity: .9;
transform: translate(0, -50%);
}
}

/* FX All The Things */
[data-science]:not([flow]):hover::before,
[data-science]:not([flow]):hover::after,
[data-science][flow^="up"]:hover::before,
[data-science][flow^="up"]:hover::after,
[data-science][flow^="down"]:hover::before,
[data-science][flow^="down"]:hover::after {
animation: data-sciences-vert 300ms ease-out forwards;
}

[data-science][flow^="left"]:hover::before,
[data-science][flow^="left"]:hover::after,
[data-science][flow^="right"]:hover::before,
[data-science][flow^="right"]:hover::after {
animation: data-sciences-horz 300ms ease-out forwards;
}
<div class="text-center">
<input id="checkbox_yoda" type="checkbox" name="character" value="light_side">
<span flow="down" data-science="Force is strong in you">
<img src="http://via.placeholder.com/350x150" alt="">
</span>
</div>

然后你通过flow right top 等等选择方向......

关于html - HTML、CSS 中的数据语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50230305/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com