gpt4 book ai didi

javascript - 添加没有html的文本悬停图像

转载 作者:行者123 更新时间:2023-11-28 15:20:01 25 4
gpt4 key购买 nike

我无权编辑 html 文件,只能编辑 css 和 js。我想在某些图像上使用悬停效果,以便弹出居中的文本。我知道图像的 div 类,但无法在正文中添加文本,如何通过 js 或 css 来实现?我应该使用类似的东西吗

element.getElementsByClassName(类名)

然后使用css?

这里来自开发者工具:

<head>
<base href="/home/">
<title>TITLE</title>
<meta name="description" content="BLA BLA BLA">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="site-id" content="19750">
<meta name="site-path" content="/home">
<meta name="site-update-url" content="https://node.sv-cdn.com/notifications">
<link rel="icon" type="image/png" href="/favicon.png">

<link rel="stylesheet" media="all" href="//smallvictories-production-assets.s3.amazonaws.com/assets/feed-23dad8deef60c63dc6e181346844e7439ba4f76c25ed84e0fb8bd63d3ce2023f.css">
<link rel="stylesheet" href="./_sv_custom.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<![endif]-->
<style>html.turbolinks-progress-bar::before {
content: '';
position: fixed;
top: 0;
left: 0;
z-index: 2000;
background-color: #0076ff;
height: 3px;
opacity: 0.99;
width: 0%;
transition: width 300ms ease-out, opacity 150ms ease-in;
transform: translate3d(0,0,0);
}</style><link rel="stylesheet" type="text/css" href="chrome-extension://onhiacboedfinnofagfgoaanfedhmfab/dist/contentStyles.css"></head>
<body id="home" class="site-19750 page home home feed" data-no-turbolink="">
<div class="sv-loader" id="sv-loader"><div class="sv-loader-loading"></div></div>
<div class="sv-theme">
<div class="sv-feed">
<div class="sv-feed-info" id="sv-feed-info" style="display: none;">
<div class="sv-feed-info-inner">
<h1 class="sv-feed-title sv-feed-info-title">WOLOBAN</h1>
<div class="sv-feed-description sv-feed-info-description"><p>BLA BLA BLA</p></div>
</div>
</div>
<a href="#sv-feed-info" class="sv-control sv-feed-control" data-sv-toggle="Info">Info</a>
<div class="sv-feed-inner">
<div class="sv-feed-block">
<div class="sv-feed-meta">
<h1 class="sv-feed-title sv-feed-meta-title">WOLOBAN</h1>
</div>
</div>
<div class="sv-feed-item sv-feed-item-0 home 01photography jpg home01photographyjpg" id="svhome01photographyjpg">
<div class="sv-feed-item-photo">
<a target="_blank" href="/HOME/PHOTOGRAPHY">
<img data-src="//aws.sv-cdn.com/site_assets/splash/3735baaa999/HOME/01-PHOTOGRAPHY.jpg" alt="01 PHOTOGRAPHY" class="lazyload lazy-loaded" src="//aws.sv-cdn.com/site_assets/splash/3735baaa999/HOME/01-PHOTOGRAPHY.jpg">
</a> <div class="sv-feed-item-photo-caption"><p>Photography</p></div>
</div>
</div>
<div class="sv-feed-item sv-feed-item-1 home 02video jpg home02videojpg" id="svhome02videojpg">
<div class="sv-feed-item-photo">
<a target="_blank" href="/HOME/VIDEO">
<img data-src="//aws.sv-cdn.com/site_assets/splash/3755baaa999/HOME/02-VIDEO.jpg" alt="02 VIDEO" class="lazyload lazy-loaded" src="//aws.sv-cdn.com/site_assets/splash/3755baaa999/HOME/02-VIDEO.jpg">
</a> <div class="sv-feed-item-photo-caption"><p>Video</p></div>
</div>
</div>
</div>
</div>
</div>

<script src="//smallvictories-production-assets.s3.amazonaws.com/assets/feed-786a3a45375601be731dc81462c9dcf2bba435942bb0dbe9cd6bef8dd17bc5b5.js"></script>
<script src="./_sv_custom.js"></script>
<span id="sbmarwbthv5"></span><a style="display: none; " id="exifview-absolute-url-convert-proxy" href="dummy"></a></body>

sv-feed-item sv-feed-item-0 home 01photography jpg home01photographyjpg"id="svhome01photographyjpg 是我要应用悬停文本的图片

最佳答案

仅 CSS 样式:

.sv-feed-item-photo > a:hover:before {
position: absolute;
font-size: 50px;
content: "This is the text!";
color: #fff;
}

关于javascript - 添加没有html的文本悬停图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46365334/

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