I have 5 divs
forming a column.
I want when I hover over one of the columns that column will increase the width by 4% and the rest will be 19%, causing an accordion effect.
I was able to do with jQuery, however it has a delay on the first use, causing it to "blink" the image when it overlaps the mouse.
I had noticed this type of flaw in another project, but I'm not finding a solution with CSS to solve.
$(".col").mouseleave(function(){
var largura = $(document).width();
if(largura>420){
$(this).css("-webkit-transition","300ms");
enter = $(this).attr("class");
$(".col").each(function (){
if($(this).attr("class") != enter){
$(this).css("width","20%");
}
});
$(this).css("width","20%");
$(this).css("filter","grayscale(100%)");
}
});
$(".col").mouseenter(function(){
var largura = $(document).width();
if(largura>420){
$(this).css("-webkit-transition","900ms");
$(this).css("filter","grayscale(0%)");
enter = $(this).attr("class");
$(".col").each(function (){
if($(this).attr("class") != enter){
$(this).css("width","19%");
}
});
$(this).css("width","24%");
}
});
.col{
width: 20%;
min-height: 678px;
height: 100%;
float: left;
position: relative;
filter: grayscale(100%);
}
.col-vestibular{
background-image: url(../img/PSP-1366.png);
background-size: auto 768px;
/*adicionado para faciltar a visualização*/
background-color: #ccc;
}
.col-enem{
background-image: url(../img/PSP-1366.png);
background-size: auto 768px;
/*adicionado para faciltar a visualização*/
background-color: #c3c;
}
.col-transferencia{
background-image: url(../img/PSP-1366.png);
background-size: auto 768px;
/*adicionado para faciltar a visualização*/
background-color: #cc3;
}
.col-segunda-graduacao{
background-image: url(../img/PSP-1366.png);
background-size: auto 768px;
/*adicionado para faciltar a visualização*/
background-color: #3cc;
}
.col-pos-graduacao{
background-image: url(../img/PSP-1366.png);
background-size: auto 768px;
/*adicionado para faciltar a visualização*/
background-color: #c33;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="container">
<div class="col col-enem" style="width: 20%; transition: 300ms; filter: grayscale(100%);">
</div>
<div class="col col-vestibular" style="width: 20%; transition: 300ms; filter: grayscale(100%);">
</div>
<div class="col col-segunda-graduacao" style="transition: 300ms; filter: grayscale(100%); width: 20%;">
</div>
<div class="col col-transferencia" style="width: 20%; transition: 300ms; filter: grayscale(100%);">
</div>
<div class="col col-pos-graduacao" style="width: 20%; transition: 300ms; filter: grayscale(100%);">
</div>
</div>