Php 用于字典模式实现的html onclick
这里是Html新手 我试图实现一个网页,弹出一些选定的技术词汇的含义,如下所示。我有一个csv格式的单词列表及其含义。如何从列表中自动选择可用单词列表的含义Php 用于字典模式实现的html onclick,php,html,Php,Html,这里是Html新手 我试图实现一个网页,弹出一些选定的技术词汇的含义,如下所示。我有一个csv格式的单词列表及其含义。如何从列表中自动选择可用单词列表的含义 <!DOCTYPE html> <html> <head> <style> .dropbtn { } .dropbtn:hover, .dropbtn:focus { background-color: #3e8e41; } .dropdown { position: r
<!DOCTYPE html>
<html>
<head>
<style>
.dropbtn {
}
.dropbtn:hover, .dropbtn:focus {
background-color: #3e8e41;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.show {display:block;}
</style>
</head>
<body>
<h2></h2>
<p>Hands-On with <div class="dropdown">
<button id="myBtn" class="dropbtn">Ultrahaptics'</button>
<div id="myDropdown" class="dropdown-content">
<a href="#home">Feel of touch without wearing devices</a>
</div>
</div>
gave us a feel of technology of future.
</p>
<script>
// Get the button, and when the user clicks on it, execute myFunction
document.getElementById("myBtn").onclick = function() {myFunction()};
/* myFunction toggles between adding and removing the show class, which is used to hide and show the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
</script>
</body>
</html>
PS:比如
<a title="Feel of touch without wearing devices">Ultrahaptics'</a>
仅适用于鼠标指针,不适用于触摸设备。因此,正在寻找一种也适用于触摸设备的解决方案。使用jQuery,这将是一个简单的例子:
$('.dropbtn').click(function(){
$(this).siblings('.dropdown-content').toggleClass('hide');
});
使用以下CSS:
.dropdown-content{
position:absolute;
background:#000;
color:#fff;
}
.hide{
display:none;
}
我简化了您的HTML:
<p>
Hands-On with
<span class="dropdown">
<button type="button" class="dropbtn">Ultrahaptics'</button>
<a href="#home" class="dropdown-content hide">Feel of touch without wearing devices</a>
</span>
gave us a feel of technology of future.
</p>
你可以在这里看到它的作用:
您可能也对使用感兴趣,但这会使您的HTML看起来有点不同。我可以看到您在使用javascript。我建议使用
这将帮助您使用javascript读取csv。您可以访问此链接,因为这与您的问题有些关联 即使在这种情况下,我也必须手动更新每次出现的技术词汇。此类事件有1000起。我正在寻找从csv文件中自动搜索技术词汇并显示其含义。不一定是动态解决方案,即使是静态解决方案也可以。每当csv文件或文章中有更新时,我都可以运行更新。@niko最简单的方法是使用MySQL之类的数据库存储数据,使用PHP之类的语言显示数据。@niko还有,您的问题是从提到CSS开始的。你所要求的与CSS无关。