CSS悬停不使用jQuery

时间:2017-10-29 14:29:05

标签: html css

这个社交媒体页脚从codepen下载,完美独立。当应用于jQuery页面时,悬停效果根本不起作用。

下面你可以查看我的代码,我希望让社交按钮的悬停属性再次可见。此处其他帖子中的!important;属性也无效。

$(function() {
  $("button").hover(function() {
    $(".content").removeClass("active");
    $("#" + $(this).data("bind")).addClass("active");
  });
});
.p{
  text-align: center;
  line-height: 100px;
}
.content {
	opacity: 0;
	position: absolute;
	-webkit-transition: 0.3s all linear;
	width: 100%;
	height: 100%;
	left: 0;
	top: -2px;
    }
.content.active {
  opacity: 1;
}

#content1 {
 background-image: url(file:///C|/Users/kaf/Desktop/My%20ultimate%20site/38e23136-b943-4487-930c-f4d7a50fccce.jpg);
	 background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover; 
}
.button {
    background:none;
    border:none;
    padding:0;
	font-size:24px;
	color:#FFF;
	margin: 10px;
	-webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;
} 
.footer {
  padding: 20px 0;
  text-align: center;
  position: absolute;
    left: 0;
    bottom: 0;
    height: 100px;
    width: 100%;
    overflow:hidden;
}
.social {
  display: inline-block;
  width: 70px;
  height: 70px;
  margin: 0 10px;
  line-height: 70px;
  font-family: Entypo;
  font-size: 35px;
  text-align: center;
  color: #999;
  border-radius: 50%;
  background: #eee;
  overflow: hidden;
  transition: color .3s;}
 .social:hover {
	color: #000 !important;
	cursor:pointer; 
}

  .social {
  box-shadow: rgb(210, 210, 210) 1px 1px,
    rgb(210, 210, 210) 2px 2px,
    rgb(211, 211, 211) 3px 3px,
    rgb(211, 211, 211) 4px 4px,
    rgb(211, 211, 211) 5px 5px,
    rgb(212, 212, 212) 6px 6px,
    rgb(212, 212, 212) 7px 7px,
    rgb(212, 212, 212) 8px 8px,
    rgb(213, 213, 213) 9px 9px,
    rgb(213, 213, 213) 10px 10px,
    rgb(214, 214, 214) 11px 11px,
    rgb(214, 214, 214) 12px 12px,
    rgb(214, 214, 214) 13px 13px,
    rgb(215, 215, 215) 14px 14px,
    rgb(215, 215, 215) 15px 15px,
    rgb(215, 215, 215) 16px 16px,
    rgb(216, 216, 216) 17px 17px,
    rgb(216, 216, 216) 18px 18px,
    rgb(216, 216, 216) 19px 19px,
    rgb(217, 217, 217) 20px 20px,
    rgb(217, 217, 217) 21px 21px,
    rgb(218, 218, 218) 22px 22px,
    rgb(218, 218, 218) 23px 23px,
    rgb(218, 218, 218) 24px 24px,
    rgb(219, 219, 219) 25px 25px,
    rgb(219, 219, 219) 26px 26px,
    rgb(219, 219, 219) 27px 27px,
    rgb(220, 220, 220) 28px 28px,
    rgb(220, 220, 220) 29px 29px,
    rgb(221, 221, 221) 30px 30px;
   text-shadow: rgb(226, 226, 226) 1px 1px,
    rgb(227, 227, 227) 2px 2px,
    rgb(227, 227, 227) 3px 3px,
    rgb(228, 228, 228) 4px 4px,
    rgb(229, 229, 229) 5px 5px,
    rgb(229, 229, 229) 6px 6px,
    rgb(230, 230, 230) 7px 7px,
    rgb(230, 230, 230) 8px 8px,
    rgb(231, 231, 231) 9px 9px,
    rgb(232, 232, 232) 10px 10px,
    rgb(232, 232, 232) 11px 11px,
    rgb(233, 233, 233) 12px 12px,
    rgb(233, 233, 233) 13px 13px,
    rgb(234, 234, 234) 14px 14px,
    rgb(235, 235, 235) 15px 15px,
    rgb(235, 235, 235) 16px 16px,
    rgb(236, 236, 236) 17px 17px,
    rgb(236, 236, 236) 18px 18px,
    rgb(237, 237, 237) 19px 19px,
    rgb(238, 238, 238) 20px 20px;
}
html >
<head>
  <meta charset="utf-8">
  <title>Alfandari&co</title>
      <link rel="stylesheet" href="css/style.css">
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> 
    
</head>
 <style>
      @import url('https://fonts.googleapis.com/css?family=Lato:300');
@import url('http://weloveiconfonts.com/api/?family=entypo');
    
      </style>
<body>
<div id="content1" class="content active">
<div class="container" align="center">
<button class="button buttonx" data-bind="content1">OUR COMPANY</button>
<button class="button buttonx" data-bind="content2">OUR HISTORY</button>
<button class="button buttonx" data-bind="content3">UNIQUE PIECES</button>
<button class="button buttonx" data-bind="content4">JEWELRY</button>
<button class="button buttonx" data-bind="content5">CONTACT US</button>
</div>
  <p>Page 1</p>
 
  <div class="footer">
  <div class="social">&#62220;</div>
  <div class="social">&#62217;</div>
  <div class="social">&#127916;</div>
 <div class="social">&#128247;</div>
 </div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
    <script src="js/index.js"></script>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

刚使用此代码:

$(function() {
  $("button").hover(function() {
    $(".content").toggleClass("active");
  });
});