简体   繁体   English

HTML / CSS Div在悬停时扩展到父div之外

[英]HTML/CSS Div Extend beyond parent div on hover

I'm wondering if the following is possible. 我想知道以下是否可能。 Have a <button> enclosed in a <div> which is enclosed in a parent <div> . <button>包含在<div> ,将其包含在父<div> On hover of the child <div> have a dropdown info panel that displays information like email and phone number. 将鼠标悬停在子<div>会有一个下拉信息面板,其中显示诸如电子邮件和电话号码之类的信息。 I've been working on this for a while (see my fiddle link below), but I can't get the drop down to appear anywhere outside of the parent <div> and moreover, the drop should appear directly below the button as opposed to on top of the button itself. 我已经为此工作了一段时间(请参阅下面的小提琴链接),但是我无法使下拉菜单显示在父<div>之外的任何位置,而且,下拉菜单应直接出现在按钮下方放在按钮本身的顶部

The button name is "Contact" 按钮名称是“联系人”

https://jsfiddle.net/wtj51d2f/5/ https://jsfiddle.net/wtj51d2f/5/

您的.navbar类溢出:隐藏阻止内容超出范围,我只是尝试删除该值,并在.drop-content类上添加一些top:50px,它显示良好。

The .drop-content has to be a child of the .dropdown element in order to be directly manipulated by it in CSS. .drop-content必须是.dropdown元素的子元素,才能在CSS中直接对其进行操作。 You can use JavaScript or jQuery to accomplish this effect, or refactor the page so that .drop-content stays within the .dropdown div. 您可以使用JavaScript或jQuery完成此效果,也可以重构页面,使.drop-content保持在.dropdown div之内。

This is what the jQuery might look like: 这就是jQuery的样子:

$('.dropdown').mouseover(function(){
    $('.drop-content').show();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM