亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

鼠標開/鼠標關(懸停)問題

鼠標開/鼠標關(懸停)問題

繁星coding 2022-01-01 20:28:59
我有 2 個按鈕按鈕 1(藍色) 按鈕 2(橙色)當我將鼠標懸停在按鈕 1 上時它變成橙色,當我將鼠標懸停時它再次變成藍色,與橙色 OK 相同現在我想要它,當我將鼠標懸停在按鈕 1(藍色)上時,按鈕 2 必須是藍色,按鈕 1 必須是橙色,當我移開它時,它必須返回到按鈕 1(藍色)和按鈕 2(橙色)用我的 CSS 和 JavaScript 腳本!我一整天都在掙扎,我對網絡編碼很陌生!$(document).ready(function() {  "use strict";  $('#slider-carousel').carouFredSel({    responsive: true,    width: '100%',    circular: true,    scroll: {      item: 1,      duration: 500,      pauseOnHover: true    },    auto: true,    items: {      visible: {        min: 1,        max: 1      },      height: "variable"    },    pagination: {      container: ".sliderpager",      pageAnchorBuilder: false    }  });});$(document).ready(function() {  $(".slider a.btn-half").mouseover(function() {    $(".slider a.btn-full").css("background-color", "deepskyblue");  });});$(document).ready(function() {  $(".slider a.btn-half").mouseout(function() {    $(".slider a.btn-full").css("background-color", "orange");  });});$(document).ready(function() {  $(".slider a.btn-full").mouseover(function() {    $(".slider a.btn-half").css("background-color", "deepskyblue");  });});$(document).ready(function() {  $(".slider a.btn-half").mouseout(function() {    $(".slider a.btn-full").css("background-color", "orange");  });});
查看完整描述

2 回答

?
慕妹3242003

TA貢獻1824條經驗 獲得超6個贊

這對你有用嗎?


$(document).ready(function() {

  $(".slider a.btn-half").mouseover(function() {

    $(".slider a.btn-full").css("background-color", "deepskyblue")

    $(".slider a.btn-half").css("background-color", "orange");

  });

});


$(document).ready(function() {

  $(".slider a.btn-half").mouseout(function() {

    $(".slider a.btn-full").css("background-color", "orange");

    $(".slider a.btn-half").css("background-color", "deepskyblue");

  });

});


$(document).ready(function() {

  $(".slider a.btn-full").mouseover(function() {

    $(".slider a.btn-full").css("background-color", "deepskyblue");

    $(".slider a.btn-half").css("background-color", "orange");

  });

});


$(document).ready(function() {

  $(".slider a.btn-full").mouseout(function() {

    $(".slider a.btn-full").css("background-color", "orange");

    $(".slider a.btn-half").css("background-color", "deepskyblue");

  });

});

只需將您的功能替換為這些功能


查看完整回答
反對 回復 2022-01-01
?
蝴蝶不菲

TA貢獻1810條經驗 獲得超4個贊

您不需要 jQuery 來執行此操作。您可以通過 CSS 僅使用“+”選擇器來實現這一點。我已經注釋掉了不必要的 JS 代碼。然后你可以添加這個CSS:


.slider a.btn-half:hover + a.btn-full

{

  background-color: deepskyblue;

}

看這個例子:


$(document).ready(function() {


  "use strict";

  $('#slider-carousel').carouFredSel({

    responsive: true,

    width: '100%',

    circular: true,

    scroll: {

      item: 1,

      duration: 5000,

      pauseOnHover: true

    },

    auto: true,

    items: {

      visible: {

        min: 1,

        max: 1

      },

      height: "variable"

    },

    pagination: {

      container: ".sliderpager",

      pageAnchorBuilder: false

    }


  });

});

/*

$(document).ready(function() {

  $(".slider a.btn-half").mouseover(function() {

    $(".slider a.btn-full").css("background-color", "deepskyblue");

  });

});

$(document).ready(function() {

  $(".slider a.btn-half").mouseout(function() {

    $(".slider a.btn-full").css("background-color", "orange");

  });

});

$(document).ready(function() {

  $(".slider a.btn-full").mouseover(function() {

    $(".slider a.btn-half").css("background-color", "deepskyblue");

  });

});

$(document).ready(function() {

  $(".slider a.btn-half").mouseout(function() {

    $(".slider a.btn-full").css("background-color", "orange");

  });

});

*/

*,

html,

body {

  margin: 0;

  padding: 0;

}


header {

  background-color: deepskyblue;

  height: 112px;

  line-height: 112px;

}


ul {

  list-style: none;

}


ul li {

  display: inline-block;

}


header nav {

  float: right;

}


header nav ul li a {

  padding-right: 30px;

  font-weight: bold;

  color: white;

  transition: 0.5s ease-in;

}


header nav ul li a:hover {

  text-decoration: none;

  color: orange;

}


.img1 {

  background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(https://via.placeholder.com/50);

  background-size: 100% 100%;

}


.slider,

.slider ul,

.slider ul li {

  height: 700px;

  width: 100%;

  color: white;

  text-align: center;

}


.slider h2 {

  font-weight: bold;

  margin-top: 220px;

}


.slider span {

  color: orange;

}


.slider a {

  padding: 10px 50px;

  ;

  margin-right: 10px;

}


.slider a.btn-half {

  background-color: deepskyblue;

  color: white;

  transition: 0.5s ease-in;

}


.slider a.btn-half:hover {

  opacity: 0.7;

  color: deepskyblue;

  background-color: orange;

  font-weight: bold;

  font-style: italic;

}


/* Add this css */

.slider a.btn-half:hover + a.btn-full

{

  background-color: deepskyblue;

}




.slider a.btn-full {

  background-color: orange;

  color: white;

  transition: 0.5s ease-in;

}


.slider a.btn-full:hover {

  opacity: 0.7;

  color: orange;

  background-color: deepskyblue;

  font-weight: bold;

  font-style: italic;

}


.img2 {

  background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(https://via.placeholder.com/50);

  background-size: 100% 100%;

}


.img3 {

  background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(https://via.placeholder.com/50);

  background-size: 100% 100%;

}


.slider i {

  font-size: 35px;

  margin-right: 10px;

}

<!doctype html>

<html>


<head>


  <title>Latinas Enteprises</title>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">

  <link rel="stylesheet" href="css/main.css">

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.caroufredsel/6.2.1/jquery.carouFredSel.packed.js"></script>


  <script src="js/caroufredsel.js"></script>

</head>


<body>


  <header>

    <div class="container">

      <div class="row">

        <a href="" class="logo"><img src="img/Logo2.png"></a>

        <nav>

          <ul>

            <li><a href="">Home</a></li>

            <li><a href="">Services</a></li>

            <li><a href="">Gallery </a></li>

            <li><a href="">Contact</a></li>

            <li><a href="">Our Team</a></li>

          </ul>

        </nav>

      </div>

    </div>

  </header>

  <section class="slider">

    <ul class="slidr-carousel" id="slider-carousel">

      <li class="img1">

        <h2>LATINAS <span>ENTERPRISES</span></h2>

        <p>We Believe In Creativity Always</p>

        <i class="fa fa-scissors"></i>

        <i class="fa fa-female"></i>

        <i class="fa fa-pencil"></i>

        <p><br> A brush of perfection!


        </p><br>

        <a href="" class="btn btn-half">Get Started</a>

        <a href="" class="btn btn-full">Call us Now!</a>

      </li>

      <li class="img2">

        <h2>LATINAS <span>ENTERPRISES</span></h2>

        <p>We Believe In Creativity Always</p>

        <i class="fa fa-scissors"></i>

        <i class="fa fa-female"></i>

        <i class="fa fa-pencil"></i>

        <p><br> A brush of perfection!


        </p><br>

        <a href="" class="btn btn-half">Get Started</a>

        <a href="" class="btn btn-full">Call us Now!</a>

      </li>

      <li class="img3">

        <h2>LATINAS <span>ENTERPRISES</span></h2>

        <p>We Believe In Creativity Always</p>

        <i class="fa fa-scissors"></i>

        <i class="fa fa-female"></i>

        <i class="fa fa-pencil"></i>

        <p><br> A brush of perfection!


        </p><br>

        <a href="" class="btn btn-half">Get Started</a>

        <a href="" class="btn btn-full">Call us Now!</a>

      </li>

    </ul>


  </section>

  <script src="js/main.js"></script>


</body>



</html>


查看完整回答
反對 回復 2022-01-01
  • 2 回答
  • 0 關注
  • 195 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號