任何人都可以帮助我如何使用CSS将鼠标悬停的详细信息下拉
这是html代码
<details>
<summary>Sample</summary>
Details of sample
</details>
Run Code Online (Sandbox Code Playgroud)
当鼠标悬停在它上面时,我需要一个css代码才能下载它可以帮助我吗?
tepkenvannkorn的解决方案可行,但在这种情况下您不需要使用JavaScript.
HTML
<div id="summary">Sample</div>
<div id="detail">Detail of this summary</div>
Run Code Online (Sandbox Code Playgroud)
(注意摘要先于细节)
CSS
#summary:hover + #detail, #detail:hover {
display: block;
}
#detail {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
尝试这个:
HTML:
<div id="summary">Sample</div>
<div id="detail">Detail of theis summary</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#summary {
background: #666;
width: 100px;
color: #fff;
}
#summary:hover {
cursor: pointer;
color: #fff200;
}
#detail {
width: 300px;
height: 300px;
background: #fff200;
display: none;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript:
$(document).ready( function() {
$('#summary').hover( function() {
$('#detail').toggle();
});
});
Run Code Online (Sandbox Code Playgroud)
在这里查看我的jsfiddle