悬停后在页脚上显示内容

时间:2017-10-01 06:56:44

标签: javascript jquery html css

抱歉标题不好。 我想在页脚中创建一个说“info”的文本,当用户将鼠标悬停在它上面时,它应显示一些文本并链接到“about us”,“return”,“size chart”等等。 它应该与本网站上的页脚https://www.lazyoaf.com/

完全相同
so this is how the footer looks before user hover over it 

enter image description here

and this is how it looks when user hover over it 

enter image description here

这是我到目前为止所尝试的

<head>
<style>
.dropbtn {
    background-color: #E0D0C3;
    color: white;
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #E0D0C3;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown-content a:hover {background-color: #E0D0C3}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown:hover .dropbtn {
    background-color: #E0D0C3;
}
</style>
</head>
<body>


<div class="dropdown">
  <button class="dropbtn">Info</button>
  <div class="dropdown-content">
    <a href="#">Link 1</a>
    <a href="#">Link 2</a>
    <a href="#">Link 3</a>
  </div>
</div>

但是这会在鼠标悬停在页脚上的“信息”文本时显示内容 我需要它在“信息”文本上方显示内容并且要更宽

1 个答案:

答案 0 :(得分:1)

我希望这会对您有所帮助

$(".footerbox").on("mouseenter", function(){
  $(this).find(".popbox").fadeIn("slow")
})


$(".footerbox").on("mouseleave", function(){
  $(this).find(".popbox").fadeOut("slow")
})
.sticky-footer{
  position: fixed;
  bottom: 30px;
  width: 100%;
}

.contents {
  height: 43px;
  width: 100%;
  position: relative;
}
   
.footerleft {
  float: left;
  width: 50%;
  background-color: grey;
  text-align: right;
}
.footerleft .label{
  padding: 20px;
}

.footerright {
  float: right;
  width: 50%;
  background-color: grey;
}

.footerbox .label{
  color: white;
}


.popbox {
  position: absolute;
  bottom: 43px;
  z-index: 999;
  width: 50%;
  background: #ebebeb;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sticky-footer">
  <div class="contents">
    <div class="footerbox footerleft">
      <span class="label">Lazy Oaf</span>
      <div class="popbox" style="display: none;">
        <div class="popbox-inner">
          <h4>Welcome to Lazy Oaf</h4>
        </div>
      </div>
    </div>
    <div class="footerbox footerright">
      <span class="label">Info</span>
      <div class="popbox" style="display: none;">
        <div class="popbox-inner">
          <h4>Info</h4>
        </div>
      </div>
    </div>
  </div><!-- contents -->
</div>