悬停时增加项目的宽度和高度

时间:2020-10-25 12:16:28

标签: javascript html css

我想在单个滑块的Width上增加Heighthover。我使用Vanilla JS制作滑块。它正在工作,但是在bottom上显示了滚动条。如果我给

    `"slideshow-wrapper="overflow: hidden;"`

然后滚动条不显示。但是项目的顶部元素未显示在hover上。在这里,我将固定的height设置为container,因此项目可以显示在其他部分上。我还使用了height

    `"overflow: hidden;"` , 

但是它变得更加复杂。项目的底部元素也没有显示。

    `<section class="career-recommendations-section theme-section">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                         <span class="slider-arrow">&#139;</span>
                        <span class="slider-arrow">&#155;</span>
                        <div class="career-recommendations-wrapper">
                            <div class="single-career-recommedation career-recommedation-hover-style">
                                <div class="career-recommedation-content">
                                    <div class="career-recommedation-content-header">
                                        <div class="career-recommedation-title">
                                            <h6>Senior Designer Manager</h6>
                                        </div>
                                        <div class="career-recommedation-badge">
                                            <svg
                                            id="Capa_1"
                                            enable-background="new 0 0 80 70"
                                            height="64"
                                            width="64"
                                            viewBox="0 0 512 512"
                                            xmlns="http://www.w3.org/2000/svg"
                                          >
                                            <g>
                                              <g>
                                                <path
                                                  d="m256 480-195-131.976v-380.024h390v380.024zm180-140.003h.293z"
                                                  fill="#00C7B2"
                                                />
                                              </g>
                                              <path
                                                d="m256 480 195-131.976v-380.024h-195z"
                                                fill="#00957A"
                                              />
                                            </g>
                                          </svg>
                                            <h3>1</h3>
                                        </div>
                                    </div>
                                    <p>We’re looking for a seasoned designer, leader and collaborator, with an amazing track in hands on directing, crafting and building world class products.</p>
                                    <div class="career-recommedation-details">
                                        <h4>Why You Fit</h4>
                                        <div class="details-inner media">
                                            <div class="media-left">
                                                <img class="ComplexProblem" src="../assets/img/employee/ComplexProblem.png" alt="">
                                            </div>
                                            <div class="media-body">
                                                <h6>Complex Problem Solving</h6>
                                            </div>
                                        </div>
                                        <div class="details-icons">
                                            <a class="button btn-color" href="#">Details</a>
                                            <ul class="details-icons-lists">
                                                <li><a class="single-details-icon active" href="#"><i class="fas fa-grin-hearts"></i></a></li>
                                                <li><a class="single-details-icon" href="#"><i class="fas fa-frown-open"></i></a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <p class="career-recommedation-cart color-one">
                                    CQ: 90%
                                </p>
                            </div>
                            <div class="single-career-recommedation career-recommedation-hover-style">
                                <div class="career-recommedation-content">
                                    <div class="career-recommedation-content-header">
                                        <div class="career-recommedation-title">
                                            <h6>UED Leader</h6>
                                        </div>
                                        <div class="career-recommedation-badge">
                                            <svg
                                            id="Capa_1"
                                            enable-background="new 0 0 80 70"
                                            height="64"
                                            width="64"
                                            viewBox="0 0 512 512"
                                            xmlns="http://www.w3.org/2000/svg"
                                          >
                                            <g>
                                              <g>
                                                <path
                                                  d="m256 480-195-131.976v-380.024h390v380.024zm180-140.003h.293z"
                                                  fill="#1C89BF"
                                                />
                                              </g>
                                              <path
                                                d="m256 480 195-131.976v-380.024h-195z"
                                                fill="#36A3C9"
                                              />
                                            </g>
                                          </svg>
                                            <h3>2</h3>
                                        </div>
                                    </div>
                                    <p>Experienced design leader and manager of a team of designers Responsible for the growth and maintenance of a high functioning team</p>

                                    <div class="career-recommedation-details">
                                        <h4>Why You Fit</h4>
                                        <div class="details-inner media">
                                            <div class="media-left">
                                                <img class="ComplexProblem" src="../assets/img/employee/ComplexProblem.png" alt="">
                                            </div>
                                            <div class="media-body">
                                                <h6>Complex Problem Solving</h6>
                                            </div>
                                        </div>
                                        <div class="details-icons">
                                            <a class="button btn-color" href="#">Details</a>
                                            <ul class="details-icons-lists">
                                                <li><a class="single-details-icon active" href="#"><i class="fas fa-grin-hearts"></i></a></li>
                                                <li><a class="single-details-icon" href="#"><i class="fas fa-frown-open"></i></a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                                <p class="career-recommedation-cart color-two">
                                    CQ: 80%
                                </p>
                            </div>
                            <div class="single-career-recommedation career-recommedation-hover-style">
                                <div class="career-recommedation-content">
                                    <div class="career-recommedation-content-header">
                                        <div class="career-recommedation-title">
                                            <h6>Senior Designer Manager</h6>
                                        </div>
                                        <div class="career-recommedation-badge">
                                            <svg
                                            id="Capa_1"
                                            enable-background="new 0 0 80 70"
                                            height="64"
                                            width="64"
                                            viewBox="0 0 512 512"
                                            xmlns="http://www.w3.org/2000/svg"
                                          >
                                            <g>
                                              <g>
                                                <path
                                                  d="m256 480-195-131.976v-380.024h390v380.024zm180-140.003h.293z"
                                                  fill="#476D77"
                                                />
                                              </g>
                                              <path
                                                d="m256 480 195-131.976v-380.024h-195z"
                                                fill="#294957"
                                              />
                                            </g>
                                          </svg>
                                            <h3>3</h3>
                                        </div>
                                    </div>
                                    <p>We’re looking for a seasoned designer, leader and collaborator, with an amazing track in hands on directing, crafting and building world class products.</p>
                                </div>
                                <p class="career-recommedation-cart color-three">
                                    CQ: 66%
                                </p>
                            </div>
                            <div class="single-career-recommedation career-recommedation-hover-style">
                                <div class="career-recommedation-content">
                                    <div class="career-recommedation-content-header">
                                        <div class="career-recommedation-title">
                                            <h6>UED Leader</h6>
                                        </div>
                                        <div class="career-recommedation-badge">
                                            <svg
                                            id="Capa_1"
                                            enable-background="new 0 0 80 70"
                                            height="64"
                                            width="64"
                                            viewBox="0 0 512 512"
                                            xmlns="http://www.w3.org/2000/svg"
                                          >
                                            <g>
                                              <g>
                                                <path
                                                  d="m256 480-195-131.976v-380.024h390v380.024zm180-140.003h.293z"
                                                  fill="#7534C2"
                                                />
                                              </g>
                                              <path
                                                d="m256 480 195-131.976v-380.024h-195z"
                                                fill="#441F69"
                                              />
                                            </g>
                                          </svg>
                                            <h3>4</h3>
                                        </div>
                                    </div>
                                    <p>Experienced design leader and manager of a team of designers Responsible for the growth and maintenance of a high functioning team</p>
                                </div>
                                <p class="career-recommedation-cart color-four">
                                    CQ: 44%
                                </p>
                            </div>
                            <div class="single-career-recommedation career-recommedation-hover-style">
                                <div class="career-recommedation-content">
                                    <div class="career-recommedation-content-header">
                                        <div class="career-recommedation-title">
                                            <h6>UED Leader</h6>
                                        </div>
                                        <div class="career-recommedation-badge">
                                            <svg
                                            id="Capa_1"
                                            enable-background="new 0 0 80 70"
                                            height="64"
                                            width="64"
                                            viewBox="0 0 512 512"
                                            xmlns="http://www.w3.org/2000/svg"
                                          >
                                            <g>
                                              <g>
                                                <path
                                                  d="m256 480-195-131.976v-380.024h390v380.024zm180-140.003h.293z"
                                                  fill="#7534C2"
                                                />
                                              </g>
                                              <path
                                                d="m256 480 195-131.976v-380.024h-195z"
                                                fill="#441F69"
                                              />
                                            </g>
                                          </svg>
                                            <h3>4</h3>
                                        </div>
                                    </div>
                                    <p>Experienced design leader and manager of a team of designers Responsible for the growth and maintenance of a high functioning team</p>
                                </div>
                                <p class="career-recommedation-cart color-four">
                                    CQ: 44%
                                </p>
                            </div>
                            <div class="single-career-recommedation career-recommedation-hover-style">
                                <div class="career-recommedation-content">
                                    <div class="career-recommedation-content-header">
                                        <div class="career-recommedation-title">
                                            <h6>UED Leader</h6>
                                        </div>
                                        <div class="career-recommedation-badge">
                                            <svg
                                            id="Capa_1"
                                            enable-background="new 0 0 80 70"
                                            height="64"
                                            width="64"
                                            viewBox="0 0 512 512"
                                            xmlns="http://www.w3.org/2000/svg"
                                          >
                                            <g>
                                              <g>
                                                <path
                                                  d="m256 480-195-131.976v-380.024h390v380.024zm180-140.003h.293z"
                                                  fill="#7534C2"
                                                />
                                              </g>
                                              <path
                                                d="m256 480 195-131.976v-380.024h-195z"
                                                fill="#441F69"
                                              />
                                            </g>
                                          </svg>
                                            <h3>4</h3>
                                        </div>
                                    </div>
                                    <p>Experienced design leader and manager of a team of designers Responsible for the growth and maintenance of a high functioning team</p>
                                </div>
                                <p class="career-recommedation-cart color-four">
                                    CQ: 44%
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>`

在CSS中:

`.career-recommendations-wrapper {
      display: flex;
    }
    .single-career-recommedation {
      flex-basis: 25%;
      transition: all 0.3s ease 0s;
    }
    .single-career-recommedation + .single-career-recommedation {
      margin-left: 20px;
    }
    .career-recommedation-content {
      background: #FFFFFF;
      border: 1px solid #D2CDCD;
      box-shadow: 0 0 4px 0 rgba(144,144,144,0.50);
      box-sizing: border-box;
      border-radius: 7px;
      padding: 15px;
      position: relative;
      transition: all 0.3s ease 0s;
    }
    .career-recommedation-content-header {
      display: flex;
      position: relative;
      justify-content: space-between;
      transition: all 0.3s ease 0s;
    }
    .career-recommedation-content-header h6 {
      font-size: 14px;
      color: #2f2f2f;
      margin-right: 14px;
      position: relative;
      text-transform: capitalize;
      padding-bottom: 10px;
      margin-bottom: 10px;
      font-weight: 600;
      font-family: Avenir-Medium;
    }
    .career-recommedation-content-header h6::before {
      position: absolute;
      content: "";
      left: 0;
      bottom: 0;
      border: 1px solid #E2E2E2;
      width: 100%;
      height: 1px;
    }

    /*  Career Badge Style   */
    .career-recommedation-badge {
      position: absolute;
      display: inline-block;
      transition: all 0.3s ease 0s;
      top: -25px;
      right: 0px;
    }
    .career-recommedation-badge h3 {
      margin-bottom: 0;
      position: absolute;
      left: 50%;
      top: 0;
      color: #fff;
      font-size: 42px;
      transform: translateX(-50%);
      transition: all 0.3s ease 0s;
    }

    .career-recommedation-title {
      max-width: 80%;
      flex-basis: 80%;
    }
    .career-recommedation-content p {
      font-size: 12px;
      color: #2F2F2F;
      line-height: 16px;
      margin: 0;
      display: inline-block;
      transition: all 0.3s ease 0s;
    }
    .career-recommedation-hover-style:hover .career-recommedation-content p {
      font-size: 14px;
      line-height: 19px;
      font-weight: 300;
    }

    .career-recommendations-section {
      position: relative;
      z-index: 2;
    }
    .career-recommendations-section .container {
      min-height: 193px;
      height: 193px;
    }
    .single-career-recommedation {
      position: relative;
      z-index: 2;
      transition: all 0.3s ease 0s;
    }
    .career-recommedation-content {
      width: 277px;
      min-height: 148px;
    /*  height: 148px;
      width: 277px;*/
      transition: all 0.3s ease 0s;
      transform: translateY(0);
    }
    .career-recommedation-hover-style:hover .career-recommedation-content {
      width: 300px;
      min-height: 356px;
    /*  height: 356px;
      width: 300px;*/
      transform: translateY(-74px);
    }
    .career-recommedation-details {
      padding: 20px 0;
      display: none;
      /*transform: translateY(-20px);*/
      transition: transform 0.3s ease 2s;
    }
    .career-recommedation-hover-style:hover .career-recommedation-details {
      display: block;
      transform: translateY(0px);
    }
    .career-recommedation-hover-style:hover .career-recommedation-cart {
      /*display: none;*/
      opacity: 0;
      visibility: hidden;
      transform: translateY(-74px);
    }


    .career-recommedation-details h4 {
      font-size: 16px;
      line-height: 22px;
      padding-bottom: 7px;
      position: relative;
    }
    .career-recommedation-details h4::before {
      position: absolute;
      content: "";
      left: 0;
      bottom: 0;
      border: 1px solid #E2E2E2;
      width: 75%;
      height: 1px;
    }

    .details-inner {
      position: relative;
      margin-bottom: 20px;
      padding: 5px 10px 10px;
      background: #f1f1f1;
      border-radius: 10px;
      width: 175px;
      align-items: center;
      justify-content: center;
    }
    .details-inner .media-body {
      align-self: center;
    }
    .details-inner h6 {
      margin-bottom: 0;
      display: inline-flex;
      font-size: 11px;
      padding-left: 5px;
    }

    .details-icons {
      display: flex;
      line-height: 1;
    }
    .details-icons .button {
      padding: 0 30px;
    }
    .details-icons-lists {
      display: flex;
      margin-left: 20px;
      align-items: center;
    }

    .details-icons-lists li + li {
      margin-left: 15px;
      align-items: center;
    }
    .details-icons-lists li a {
      font-size: 36px;
      color: #6F7B85;
    }
    .details-icons-lists li a.active {
      color: #FFAA0C;
    }

` 香草JS:

`   var arrow = document.getElementsByClassName('slider-arrow');
var slide = document.getElementsByClassName('career-recommendations-wrapper');

var l = 0;

arrow[1].onclick = ()=> {

    l++;
    for (var i of slide) {

        if (l == 0) { i.style.left = "0px";}
        if (l == 1) { i.style.left = "-600px";}
        if (l == 2) { i.style.left = "-1200px";}
        // if (l == 3) { i.style.left = "-1800px";}
        // if (l == 4) { i.style.left = "-2400px";}
        if (l > 2) { l = 2;}
    }
    
}

arrow[0].onclick = ()=> {
    l--;
    for (var i of slide) {
        if (l == 0) { i.style.left = "0px";}
        if (l == 1) { i.style.left = "-600px";}
        if (l == 2) { i.style.left = "-1200px";}
        // if (l == 3) { i.style.left = "-1800px";}
        if (l < 0) { l = 0;}
    }
}`
    

>First Stage - slide a item and Shows scrollbar on bottom
>Hover on a item, it's working without scrollbar >Setting overflow in Slider wrapper >Setting overflow and height in container

在这里您可以了解一些想法。 https://jsfiddle.net/ashiqsetu/uq3t4b6w/2/

实际上我想要这样的悬停效果: On hover effect

https://www.linkedin.com/learning/me

0 个答案:

没有答案