RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 997594
Accepted
John
John
Asked:2020-06-29 14:41:48 +0000 UTC2020-06-29 14:41:48 +0000 UTC 2020-06-29 14:41:48 +0000 UTC

jquery中特定元素的事件上下文

  • 772

资源:

产品卡片

let product     = $('.product');
  let productLink = product.find('.product__link');
  let productFrame = product.find('.product__frame');
  let productImages = product.find('.product__images');

  product.on('mouseover', function () {

    productLink.html('detail').addClass('visible');
    productFrame.addClass('active');
    productImages.addClass('hidden');

  });

  product.on('mouseout', function () {

    productLink.html('').removeClass('visible');
    productFrame.removeClass('active');
    productImages.removeClass('hidden');

  });

概括:

在这个布局中,有需要动画的产品卡片。当光标悬停在产品卡片上时,出于某种原因,它会应用于所有人。我试图通过循环,jq 仍然发誓。通过互联网翻遍每一个()。但是没看懂!

问题: 那么如何通过循环并为 jq 中的特定元素创建上下文(以便只有一张卡片有动画)?也许还有其他方法?

javascript
  • 2 2 个回答
  • 10 Views

2 个回答

  • Voted
  1. Владислав
    2020-06-29T15:18:41Z2020-06-29T15:18:41Z

    var target,
      productLink,
      productFrame,
      productImages;
    
    document.body.addEventListener('mouseover', () => {
      target = event.target;
    
      while (target != document.body) {
        if (target.tagName == 'LI' && !target.classList.contains('title-link')){
          // нашли элемент, который нас интересует!
          productLink = target.querySelector('.product__link-wrap');
          productFrame = target.querySelector('.product__frame');
          productImages = target.querySelector('.product__images');
    
          productLink.classList.add('visible');
          productFrame.classList.add('active');
          productImages.classList.add('hidden');
    
          return;
        }
    
        target = target.parentNode;
      }
    })
    
    document.body.addEventListener('mouseout', () => {
    
      if (target.tagName == 'LI' && !target.classList.contains('title-link')) {
        productLink.classList.remove('visible');
        productFrame.classList.remove('active');
        productImages.classList.remove('hidden');
      }
    
    })
    html {
      line-height: 1.15;
      -webkit-text-size-adjust: 100%
    }
    
    body {
      margin: 0
    }
    
    details,
    main {
      display: block
    }
    
    h1 {
      font-size: 2em;
      margin: .67em 0
    }
    
    hr {
      box-sizing: content-box;
      height: 0;
      overflow: visible
    }
    
    code,
    kbd,
    pre,
    samp {
      font-family: monospace, monospace;
      font-size: 1em
    }
    
    a {
      background-color: transparent
    }
    
    abbr[title] {
      border-bottom: none;
      text-decoration: underline;
      text-decoration: underline dotted
    }
    
    b,
    strong {
      font-weight: bolder
    }
    
    small {
      font-size: 80%
    }
    
    sub,
    sup {
      font-size: 75%;
      line-height: 0;
      position: relative;
      vertical-align: baseline
    }
    
    sub {
      bottom: -.25em
    }
    
    sup {
      top: -.5em
    }
    
    img {
      border-style: none
    }
    
    button,
    input,
    optgroup,
    select,
    textarea {
      font-family: inherit;
      font-size: 100%;
      line-height: 1.15;
      margin: 0
    }
    
    button,
    input {
      overflow: visible
    }
    
    button,
    select {
      text-transform: none
    }
    
    [type=button],
    [type=reset],
    [type=submit],
    button {
      -webkit-appearance: button
    }
    
    [type=button]::-moz-focus-inner,
    [type=reset]::-moz-focus-inner,
    [type=submit]::-moz-focus-inner,
    button::-moz-focus-inner {
      border-style: none;
      padding: 0
    }
    
    [type=button]:-moz-focusring,
    [type=reset]:-moz-focusring,
    [type=submit]:-moz-focusring,
    button:-moz-focusring {
      outline: ButtonText dotted 1px
    }
    
    fieldset {
      padding: .35em .75em .625em
    }
    
    legend {
      box-sizing: border-box;
      color: inherit;
      display: table;
      max-width: 100%;
      padding: 0;
      white-space: normal
    }
    
    progress {
      vertical-align: baseline
    }
    
    textarea {
      overflow: auto
    }
    
    [type=checkbox],
    [type=radio] {
      box-sizing: border-box;
      padding: 0
    }
    
    [type=number]::-webkit-inner-spin-button,
    [type=number]::-webkit-outer-spin-button {
      height: auto
    }
    
    [type=search] {
      -webkit-appearance: textfield;
      outline-offset: -2px
    }
    
    [type=search]::-webkit-search-decoration {
      -webkit-appearance: none
    }
    
     ::-webkit-file-upload-button {
      -webkit-appearance: button;
      font: inherit
    }
    
    summary {
      display: list-item
    }
    
    [hidden],
    template {
      display: none
    }
    
    @font-face {
      font-family: 'Source Sans Pro';
      font-weight: 200;
      font-style: normal;
      font-stretch: normal;
      src: url('../fonts/SourceSansPro-ExtraLight.ttf.woff2') format('woff2'), url('../fonts/SourceSansPro-ExtraLight.otf.woff') format('woff'), url('../fonts/SourceSansPro-ExtraLight.otf') format('opentype'), url('../fonts/SourceSansPro-ExtraLight.ttf') format('truetype');
    }
    
    @font-face {
      font-family: 'Source Sans Pro';
      font-weight: 300;
      font-style: normal;
      font-stretch: normal;
      src: url('../fonts/SourceSansPro-Light.ttf.woff2') format('woff2'), url('../fonts/SourceSansPro-Light.otf.woff') format('woff'), url('../fonts/SourceSansPro-Light.otf') format('opentype'), url('../fonts/SourceSansPro-Light.ttf') format('truetype');
    }
    
    @font-face {
      font-family: 'Source Sans Pro';
      font-weight: 400;
      font-style: normal;
      font-stretch: normal;
      src: url('../fonts/SourceSansPro-Regular.ttf.woff2') format('woff2'), url('../fonts/SourceSansPro-Regular.otf.woff') format('woff'), url('../fonts/SourceSansPro-Regular.otf') format('opentype'), url('../fonts/SourceSansPro-Regular.ttf') format('truetype');
    }
    
    @font-face {
      font-family: 'Source Sans Pro';
      font-weight: 600;
      font-style: normal;
      font-stretch: normal;
      src: url('../fonts/SourceSansPro-Semibold.ttf.woff2') format('woff2'), url('../fonts/SourceSansPro-Semibold.otf.woff') format('woff'), url('../fonts/SourceSansPro-Semibold.otf') format('opentype'), url('../fonts/SourceSansPro-Semibold.ttf') format('truetype');
    }
    
    @font-face {
      font-family: 'Source Sans Pro';
      font-weight: 700;
      font-style: normal;
      font-stretch: normal;
      src: url('../fonts/SourceSansPro-Bold.ttf.woff2') format('woff2'), url('../fonts/SourceSansPro-Bold.otf.woff') format('woff'), url('../fonts/SourceSansPro-Bold.otf') format('opentype'), url('../fonts/SourceSansPro-Bold.ttf') format('truetype');
    }
    
    @font-face {
      font-family: 'Source Sans Pro';
      font-weight: 900;
      font-style: normal;
      font-stretch: normal;
      src: url('../fonts/SourceSansPro-Black.ttf.woff2') format('woff2'), url('../fonts/SourceSansPro-Black.otf.woff') format('woff'), url('../fonts/SourceSansPro-Black.otf') format('opentype'), url('../fonts/SourceSansPro-Black.ttf') format('truetype');
    }
    
    @font-face {
      font-family: 'Source Sans Pro';
      font-weight: 900;
      font-style: italic;
      font-stretch: normal;
      src: url('WOFF2/TTF/SourceSansPro-BlackIt.ttf.woff2') format('woff2'), url('WOFF/OTF/SourceSansPro-BlackIt.otf.woff') format('woff'), url('OTF/SourceSansPro-BlackIt.otf') format('opentype'), url('TTF/SourceSansPro-BlackIt.ttf') format('truetype');
    }
    
    html,
    body {
      margin: 0;
      padding: 0;
      background-color: #fff;
      font: normal 14px/24px "Source Sans Pro";
      text-transform: uppercase;
      letter-spacing: 1px;
    }
    
    ul,
    li,
    p,
    h1,
    h2,
    h3,
    h4 {
      padding: 0;
      margin: 0;
      list-style: none;
    }
    
    img {
      max-width: 100%;
      height: auto;
    }
    
    a {
      text-decoration: none;
    }
    
    * {
      box-sizing: border-box;
    }
    
    .container {
      max-width: 1180px;
      margin: auto;
      padding: 0 20px;
    }
    
    .container-wrap {
      max-width: 1610px;
      margin: auto;
      background-color: #fbfbfb;
    }
    
    .header__top {
      padding-top: 25px;
      padding-bottom: 20px;
    }
    
    .top-header {
      display: -webkit-box;
      display: flex;
      -webkit-box-pack: justify;
      justify-content: space-between;
    }
    
    .top-header__text {
      color: #323232;
      font-size: 13px;
      line-height: 12px;
      padding-right: 10px;
    }
    
    .top-header__text:hover {
      color: #656565;
    }
    
    .top-header__text_bold {
      font-weight: 700;
      cursor: default;
    }
    
    .top-header__text_bold:hover {
      color: #323232;
    }
    
    .middle-header {
      display: -webkit-box;
      display: flex;
      -webkit-box-pack: justify;
      justify-content: space-between;
      padding-top: 30px;
    }
    
    .middle-header__col-1 {
      max-width: 300px;
    }
    
    .middle-header__col-2 {
      margin-top: -50px;
    }
    
    .middle-header__col-3 {
      width: 420px;
    }
    
    .login__text {
      font-size: 13px;
      color: #656565;
      background-repeat: no-repeat;
      background-position: left;
      margin-bottom: 15px;
      padding-left: 25px;
      font-weight: 400;
      letter-spacing: 2px;
    }
    
    .login__text_white {
      background-color: #e1bc62;
      color: #fff;
      padding: 0 2px;
      font-weight: 600;
    }
    
    .login__text_white:hover {
      background-color: #e9ce8d;
    }
    
    .login__text_user {
      background-image: url('../img/user-icon.svg');
    }
    
    .login__text_phone {
      background-image: url('../img/phone-icon.svg');
      text-transform: capitalize;
    }
    
    .login__text_phone .phone-num {
      font-size: 15px;
    }
    
    .login__search input {
      width: 100%;
      padding: 15px 15px;
      background-repeat: no-repeat;
      background-image: url('../img/search-icon.svg');
      background-position: 95% 50%;
      border: 1px solid #bebebe;
    }
    
    .login__search input::-webkit-input-placeholder {
      text-transform: uppercase;
      color: #989898;
    }
    
    .login__search input::-moz-placeholder {
      text-transform: uppercase;
      color: #989898;
    }
    
    .login__search input:-ms-input-placeholder {
      text-transform: uppercase;
      color: #989898;
    }
    
    .login__search input::-ms-input-placeholder {
      text-transform: uppercase;
      color: #989898;
    }
    
    .login__search input::placeholder {
      text-transform: uppercase;
      color: #989898;
    }
    
    .sold__item {
      display: -webkit-box;
      display: flex;
    }
    
    .sold__item_top {
      font-size: 14px;
      color: #323232;
    }
    
    .sold__item_middle {
      border: 1px solid #ccc;
      border-top: 0;
      padding: 15px;
    }
    
    .sold__link {
      font-size: 14px;
      color: #323232;
      text-align: center;
      position: relative;
      padding: 15px 0;
    }
    
    .sold__link:hover {
      color: #656565;
    }
    
    .sold__link_wishlist {
      width: 180px;
      padding-left: 23px;
    }
    
    .sold__link_cart {
      -webkit-box-flex: 1;
      flex-grow: 1;
      padding-left: 15px;
    }
    
    .sold__link.active {
      border: 1px solid #ccc;
      border-bottom: 0 solid #ccc;
    }
    
    .sold__link .icon {
      width: 23px;
      height: 23px;
      background-repeat: no-repeat;
      display: inline-block;
      background-position: center;
      position: absolute;
    }
    
    .sold__link .icon_wishlist {
      background-image: url('../img/wishlist.png');
      left: 30px;
    }
    
    .sold__link .icon_cart {
      background-image: url('../img/cart-icon.png');
      left: 15px;
    }
    
    .sold__link .total-sum {
      color: #cd222a;
      font-weight: 900;
      letter-spacing: 1px;
      font-size: 13px;
    }
    
    .sold__link .total-sum_padding {
      padding-left: 57px;
    }
    
    .sold__link .amount {
      position: absolute;
      width: 18px;
      height: 18px;
      background-color: #cd222a;
      border-radius: 50%;
      color: #fff;
      font-size: 13px;
      font-weight: 900;
      line-height: 18px;
      left: 9px;
      top: 9px;
    }
    
    .sold__product {
      -webkit-box-flex: 1;
      flex-grow: 1;
      position: relative;
    }
    
    .sold__product .delete {
      position: absolute;
      width: 12px;
      height: 12px;
      right: 20px;
      cursor: pointer;
      top: 50%;
      margin-top: -5px;
    }
    
    .sold__product .delete:before,
    .sold__product .delete:after {
      content: '';
      position: absolute;
      display: block;
      width: 1.5px;
      height: 12px;
      background-color: #ccc;
      right: 50%;
      margin-right: -1px;
      -webkit-transform: rotate(35deg);
      -ms-transform: rotate(35deg);
      transform: rotate(35deg);
    }
    
    .sold__product .delete:after {
      -webkit-transform: rotate(-35deg);
      -ms-transform: rotate(-35deg);
      transform: rotate(-35deg);
    }
    
    .sold__title,
    .sold__price {
      color: #656565;
      text-transform: uppercase;
    }
    
    .sold__title {
      font-weight: 700;
      font-size: 12px;
    }
    
    .sold__img {
      float: left;
      margin-right: 15px;
    }
    
    .sold__price {
      font-weight: 400;
      font-size: 16px;
      line-height: 18px;
    }
    
    .sold__btn {
      text-align: center;
      line-height: 16px;
      padding: 11px;
    }
    
    .sold__btn_first {
      -webkit-box-flex: 1;
      flex-grow: 1;
      background-color: #383739;
    }
    
    .sold__btn_first:hover {
      background-color: #525053;
    }
    
    .sold__btn_second {
      width: 180px;
      background-color: #e1bc62;
      position: relative;
    }
    
    .sold__btn_second:hover {
      background-color: #e9ce8d;
    }
    
    .sold__btn .text {
      color: #fff;
      font-weight: 600;
    }
    
    .sold__btn .plus {
      width: 12px;
      height: 12px;
      position: relative;
      display: inline-block;
      margin-right: 8px;
    }
    
    .sold__btn .plus:before,
    .sold__btn .plus:after {
      content: '';
      position: absolute;
      display: block;
      background-color: #fff;
      height: 12px;
      width: 2px;
      right: 50%;
      margin-right: -0.5px;
    }
    
    .sold__btn .plus:after {
      -webkit-transform: rotate(90deg);
      -ms-transform: rotate(90deg);
      transform: rotate(90deg);
    }
    
    .sold__btn .checkout {
      background-image: url('../img/checkout-icon.svg');
      position: absolute;
      width: 24px;
      height: 24px;
      background-position: center;
      display: inline-block;
      background-repeat: no-repeat;
      left: 20px;
      top: 50%;
      margin-top: -12px;
    }
    
    .nav_margin {
      padding: 20px 0;
      position: relative;
    }
    
    .nav_margin:after {
      content: '';
      position: absolute;
      display: block;
      height: 5px;
      background-color: #e1bc62;
      width: 100%;
      bottom: 0;
      left: 0;
    }
    
    .nav-list {
      display: -webkit-box;
      display: flex;
      -webkit-box-pack: center;
      justify-content: center;
    }
    
    .nav-list__item {
      margin-right: 28px;
      margin-left: 28px;
      line-height: 15px;
    }
    
    .nav-list__link {
      color: #444444;
      font-weight: 600;
      font-size: 15px;
      text-transform: uppercase;
    }
    
    .nav-list__link:hover {
      color: #777777;
    }
    
    .shop-window {
      display: -webkit-box;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
      flex-direction: column;
      flex-wrap: wrap;
      -webkit-box-pack: start;
      justify-content: flex-start;
      align-content: flex-start;
      height: 680px;
      margin: -10px;
    }
    
    .shop-window_padding20px {
      padding-top: 20px;
    }
    
    .shop-window__col {
      margin: 10px;
      overflow: hidden;
      position: relative;
    }
    
    .shop-window__col img {
      display: block;
    }
    
    .shop-window__col_1 {
      height: 100%;
      width: calc(100% / 12 * 3 - 20px);
    }
    
    .shop-window__col_2 {
      height: calc(100% / 12 * 6 - 20px);
      width: calc(100% / 12 * 6 - 20px);
    }
    
    .shop-window__col_3 {
      height: calc(100% / 12 * 6 - 20px);
      width: calc(100% / 12 * 3 - 20px);
    }
    
    .shop-window__col_4 {
      height: calc(100% / 12 * 6 - 20px);
      width: calc(100% / 12 * 3 - 20px);
    }
    
    .shop-window__col_5 {
      background-color: black;
      height: calc(100% / 12 * 6 - 20px);
      width: calc(100% / 12 * 6 - 20px);
      margin-left: calc((100% / 12 * 3 - 10px)*-1);
    }
    
    .collections__wrap-img {
      position: relative;
    }
    
    .collections__wrap-img:before {
      content: '';
      position: absolute;
      display: block;
      background-color: #fff;
      z-index: 100;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      opacity: 0.4;
    }
    
    .collections__wrap-block {
      position: absolute;
      top: 60%;
      left: 0;
      width: 100%;
      text-align: center;
      z-index: 1000;
    }
    
    .collections__month {
      font-size: 36px;
      color: #000;
      letter-spacing: 2px;
    }
    
    .collections__month span {
      display: block;
      font-size: 12px;
      text-transform: capitalize;
      font-weight: 400;
      letter-spacing: 10px;
    }
    
    .collections__link {
      display: block;
      margin: auto;
      margin-top: 10px;
      padding: 15px;
      text-align: center;
      background: #e1bc62;
      width: 60%;
      font-size: 14px;
      line-height: 14px;
      text-transform: capitalize;
      color: #fff;
      font-weight: 700;
    }
    
    .collections__link:hover {
      background: #e9ce8d;
    }
    
    .sale {
      position: relative;
    }
    
    .sale__img {
      display: block;
    }
    
    .sale__sticker {
      position: absolute;
      top: 0;
      left: 0;
      overflow: hidden;
      width: 60px;
      height: 38px;
    }
    
    .sale__sticker:before {
      content: '';
      position: absolute;
      display: block;
      border-left: 25px solid transparent;
      border-bottom: 25px solid transparent;
      border-right: 25px solid #e1bc62;
      border-top: 25px solid #e1bc62;
      z-index: 200;
      -webkit-transform: rotate(-77deg);
      -ms-transform: rotate(-77deg);
      transform: rotate(-77deg);
      top: -18px;
      left: -1px;
    }
    
    .sale__text {
      color: #fff;
      letter-spacing: 5px;
      background-color: #e1bc62;
      position: absolute;
      z-index: 100;
      -webkit-transform: rotate(-32deg);
      -ms-transform: rotate(-32deg);
      transform: rotate(-32deg);
      top: 8px;
      line-height: 12px;
      width: 93px;
      box-shadow: 0 0 4px 1px black;
      text-align: center;
      left: -25px;
      font-size: 12px;
      padding-left: 4px;
    }
    
    .block-3__img {
      height: 100%;
    }
    
    .block-5__img {
      height: 100%;
    }
    
    .arrivals__wrap-img:before {
      content: '';
      position: absolute;
      display: block;
      background-color: #fff;
      z-index: 100;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      opacity: 0.4;
    }
    
    .arrivals__wrap-block {
      position: absolute;
      top: 35%;
      left: 0;
      width: 100%;
      text-align: center;
      z-index: 1000;
    }
    
    .arrivals__text {
      font-size: 32px;
      letter-spacing: 10px;
      font-weight: 100;
      text-align: center;
    }
    
    .arrivals__text span {
      font-size: 42px;
      font-weight: 900;
      display: block;
      text-align: center;
      letter-spacing: 1px;
    }
    
    .arrivals__link {
      display: block;
      margin: auto;
      margin-top: 10px;
      padding: 15px;
      text-align: center;
      background: #e1bc62;
      width: 60%;
      font-size: 14px;
      line-height: 14px;
      text-transform: capitalize;
      color: #fff;
      font-weight: 700;
    }
    
    .arrivals__link:hover {
      background: #e9ce8d;
    }
    
    .products_padding85 {
      padding-top: 90px;
    }
    
    .products_mod {
      display: -webkit-box;
      display: flex;
      flex-wrap: wrap;
      margin-right: -7px;
      margin-left: -7px;
    }
    
    .products__title {
      width: 100%;
      margin-bottom: 55px;
    }
    
    .products__item {
      width: calc(100% / 12 * 3 - 14px);
      margin-left: 7px;
      margin-right: 7px;
      display: -webkit-box;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
      flex-direction: column;
      -webkit-box-align: center;
      align-items: center;
    }
    
    .title-link__titles {
      display: -webkit-box;
      display: flex;
      -webkit-box-pack: center;
      justify-content: center;
      position: relative;
      margin-bottom: 30px;
    }
    
    .title-link__titles:before {
      content: '';
      position: absolute;
      display: block;
      width: 2px;
      height: 100%;
      background: #d6d6d6;
      right: 50%;
      margin-right: -4px;
    }
    
    .title-link__title {
      font-size: 48px;
      color: #595959;
      padding-right: 60px;
      line-height: 35px;
      position: relative;
      font-weight: 100;
      -webkit-transition: 1s;
      transition: 1s;
    }
    
    .title-link__title:hover .arrow {
      -webkit-transform: rotate(405deg);
      -ms-transform: rotate(405deg);
      transform: rotate(405deg);
    }
    
    .title-link__title.active {
      font-weight: 900;
      color: #000;
    }
    
    .title-link__title.active:hover {
      cursor: default;
    }
    
    .title-link__title.active:hover .arrow {
      -webkit-transform: rotate(45deg);
      -ms-transform: rotate(45deg);
      transform: rotate(45deg);
    }
    
    .title-link__title_second {
      margin-left: 15px;
    }
    
    .title-link__title .arrow {
      position: absolute;
      width: 12px;
      height: 12px;
      border-right: 1px solid;
      border-bottom: 1px solid;
      right: 30px;
      top: 50%;
      margin-top: -6px;
      -webkit-transform: rotate(45deg);
      -ms-transform: rotate(45deg);
      transform: rotate(45deg);
      -webkit-transition: 1s;
      transition: 1s;
    }
    
    .title-link__advantages {
      text-align: center;
      color: #595959;
      letter-spacing: 2px;
      text-transform: initial;
      font-style: italic;
      line-height: 14px;
    }
    
    .product {
      position: relative;
    }
    
    .product div,
    .product a {
      position: relative;
      z-index: 100;
    }
    
    .product:before {
      content: '';
      position: absolute;
      display: block;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: #fff;
      z-index: 20;
    }
    
    .product__images {
      position: relative;
      display: block;
      margin-bottom: 15px;
    }
    
    .product__images:before {
      content: '';
      position: absolute;
      display: block;
      background-color: #fff;
      z-index: 1000;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      opacity: 0.4;
    }
    
    .product__images:after {
      content: '';
      position: absolute;
      display: block;
      width: 44px;
      height: 2px;
      right: 50%;
      margin-right: -22px;
      bottom: -7px;
      background-color: #595959;
    }
    
    .product__images.hidden:before {
      opacity: 0;
    }
    
    .product__image img {
      display: block;
      width: 100%;
      height: 290px;
    }
    
    .product__link-wrap {
      min-height: 17px;
      margin-bottom: 15px;
    }
    
    .product__link {
      width: 65px;
      text-align: center;
      color: #fff;
      line-height: 17px;
      font-size: 13px;
      border-radius: 10px;
      display: block;
      letter-spacing: 2px;
      min-height: 16px;
      margin: auto;
      -webkit-transition: 1s;
      transition: 1s;
    }
    
    .product__link.visible {
      background-color: #383739;
    }
    
    .product__title {
      margin-bottom: 7px;
    }
    
    .product__title .text {
      color: #595959;
      font-size: 18px;
      font-weight: 700;
      line-height: 24px;
    }
    
    .product__price {
      text-align: center;
      line-height: 17px;
    }
    
    .product__price .old-price,
    .product__price .price {
      color: #595959;
      font-weight: 100;
    }
    
    .product__price .old-price {
      font-size: 13px;
      text-decoration: line-through;
    }
    
    .product__price .price {
      font-size: 16px;
    }
    
    .product__frame {
      position: absolute !important;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: transparent;
      z-index: 10 !important;
      margin: -10px;
      -webkit-transition: 0.5s;
      transition: 0.5s;
      border: 3px solid transparent;
    }
    
    .product__frame.active {
      background-color: #e1bc62;
      border-color: #000;
    }
    <div class="container">
    
      <ul class="products products_mod products_padding85">
        <li class="title-link products__title">
          <div class="title-link__titles">
            <a class="title-link__title active" href="">
                      FEATURED
                      <span class="arrow"></span>
                   </a>
    
            <a class="title-link__title title-link__title_second" href="">
                      ARRIVALS
                      <span class="arrow"></span>
                   </a>
          </div>
          <p class="title-link__advantages">“Whoever said money can’t buy happiness simply didn’t know WHER</p>
        </li>
    
        <li class="product products__item">
          <a class="product__images" href="#">
    
            <div class="product__image">
              <img src="http://lorempixel.com/285/300/sports/1" alt="">
            </div>
    
          </a>
          <div class="product__link-wrap">
            <a class="product__link " href="">
    
            </a>
          </div>
          <div class="product__title">
            <span class="text">slim pants</span>
          </div>
    
          <div class="product__price">
    
            <span class="old-price">$329,00</span>
            <span class="price">$279,00</span>
          </div>
          <div class="product__cart">
            <h3 class="text">ADD TO CART</h3>
          </div>
          <div class="product__wishlist">
            <span class="icon"></span>
            <span class="text"></span>
          </div>
          <div class="product__frame"></div>
        </li>
        <li class="product products__item">
          <a class="product__images" href="#">
    
            <div class="product__image">
              <img src="http://lorempixel.com/285/300/sports/1" alt="">
            </div>
    
          </a>
          <div class="product__link-wrap">
            <a class="product__link " href="">
    
            </a>
          </div>
          <div class="product__title">
            <span class="text">slim pants</span>
          </div>
    
          <div class="product__price">
    
            <span class="old-price">$329,00</span>
            <span class="price">$279,00</span>
          </div>
          <div class="product__cart">
            <h3 class="text">ADD TO CART</h3>
          </div>
          <div class="product__wishlist">
            <span class="icon"></span>
            <span class="text"></span>
          </div>
          <div class="product__frame"></div>
        </li>
        <li class="product products__item">
          <a class="product__images" href="#">
    
            <div class="product__image">
              <img src="http://lorempixel.com/285/300/sports/1" alt="">
            </div>
    
          </a>
          <div class="product__link-wrap">
            <a class="product__link " href="">
    
            </a>
          </div>
          <div class="product__title">
            <span class="text">slim pants</span>
          </div>
    
          <div class="product__price">
    
            <span class="old-price">$329,00</span>
            <span class="price">$279,00</span>
          </div>
          <div class="product__cart">
            <h3 class="text">ADD TO CART</h3>
          </div>
          <div class="product__wishlist">
            <span class="icon"></span>
            <span class="text"></span>
          </div>
          <div class="product__frame"></div>
        </li>
        <li class="product products__item">
          <a class="product__images" href="#">
    
            <div class="product__image">
              <img src="http://lorempixel.com/285/300/sports/1" alt="">
            </div>
    
          </a>
          <div class="product__link-wrap">
            <a class="product__link " href="">
    
            </a>
          </div>
          <div class="product__title">
            <span class="text">slim pants</span>
          </div>
    
          <div class="product__price">
    
            <span class="old-price">$329,00</span>
            <span class="price">$279,00</span>
          </div>
          <div class="product__cart">
            <h3 class="text">ADD TO CART</h3>
          </div>
          <div class="product__wishlist">
            <span class="icon"></span>
            <span class="text"></span>
          </div>
          <div class="product__frame"></div>
        </li>
    
      </ul>
    </div>

    如果它在 jQuery 上工作对您来说并不重要,那么就是这样。

    2)你可以不用脚本:

    li:hover .product__frame {
       background-color: #e1bc62;
       border-color: #000;
    }
    
    li:hover .product__link {
       background-color: #383739;
    }
    
    • 1
  2. Best Answer
    Jigius
    2020-06-29T16:02:12Z2020-06-29T16:02:12Z

    带有 jQ​​uery 的选项:

    $('.product')
        .on('mouseover', function (event) {
          $(this).find('.product__link').html('detail').addClass('visible');
          $(this).find('.product__frame').addClass('active');
          $(this).find('.product__images').addClass('hidden');
        })
        .on('mouseout', function (event) {
          $(this).find('.product__link').html('').removeClass('visible');
          $(this).find('.product__frame').removeClass('active');
          $(this).find('.product__images').removeClass('hidden');
     });
    

    密码笔

    • 1

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    根据浏览器窗口的大小调整背景图案的大小

    • 2 个回答
  • Marko Smith

    理解for循环的执行逻辑

    • 1 个回答
  • Marko Smith

    复制动态数组时出错(C++)

    • 1 个回答
  • Marko Smith

    Or and If,elif,else 构造[重复]

    • 1 个回答
  • Marko Smith

    如何构建支持 x64 的 APK

    • 1 个回答
  • Marko Smith

    如何使按钮的输入宽度?

    • 2 个回答
  • Marko Smith

    如何显示对象变量的名称?

    • 3 个回答
  • Marko Smith

    如何循环一个函数?

    • 1 个回答
  • Marko Smith

    LOWORD 宏有什么作用?

    • 2 个回答
  • Marko Smith

    从字符串的开头删除直到并包括一个字符

    • 2 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5