javascript - 悬停时增加项目的宽度和高度
问题描述
我想增加Width
一个滑块单项Height
。hover
我使用 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">‹</span>
<span class="slider-arrow">›</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;}
}
}`
>第一阶段 - 滑动一个项目并在底部显示滚动条
>悬停在一个项目上,它在没有滚动条的情况下工作
>overflow
在滑块包装器
中设置 >设置overflow
和height
container
在这里你可以得到一点想法。 https://jsfiddle.net/ashiqsetu/uq3t4b6w/2/
其实我想要这样的悬停效果: On hover effect
解决方案
推荐阅读
- python - 使用python读取vb文件时无法识别的符号
- php - PHP MYSQL ODBC 连接成功但未检索数据
- amazon-web-services - 如何将 AWS 应用程序负载均衡器和 NAT 网关配置为具有公共 IP
- node.js - 如何在 Apple Silicon M1 上原生安装 NodeJS?
- excel - Power Pivot 2016 中的 DAX 计算度量
- python - Python3 不正确的 AES 密钥长度(256 字节)
- reactjs - Firebase 提取时间过长
- php - 这个文件操作真的是“原子的”和“安全的”吗?如果没有,我怎么能做到这一点?
- asp.net-core - 在 Docker Compose 环境中运行时,ASP.NET Core WebApplicationFactory CreateClient 在 GitLab CI 上启动服务器阻塞
- python - 如何以编程方式报告数据集中合理的局部最大值和最小值?