이미지를 클릭하면 div가 페이드 인 된 다음 페이드 아웃됩니다. 이 div는 항상 같은 공간 (display: block
)을 차지해야합니다. 다시 클릭하면이 div가 다시 나타납니다.페이드 아웃 후 페이딩 또는 페이드 후 디스플레이 블록
이것을 수행 할 수 없습니다. fadeOut()
을 사용하는 경우 인라인 스타일 display:none
이 추가됩니다. fadeTo()
을 사용하면 div는 공간을 차지하지 않고 숨겨집니다.
어떻게해야합니까?
코드 :
function edit(oneid)
{
AvisEdit(oneid);
}
function AvisEdit(oneid)
{
\t var nom = $('#X'+oneid+' .Nom').text();
\t ShowAlerts("Ara pots editar el valor dels camps de '"+nom+"'", 2);
}
function ShowAlerts(sms, code)
{
\t switch(code)
\t {
\t \t case 0:
\t \t \t Actions(sms, "success");
\t \t \t break;
\t \t
\t \t case 1:
\t \t \t Actions(sms, "error");
\t \t \t break;
\t \t case 2:
\t \t \t Actions(sms, "info");
\t \t \t break;
\t }
}
function Actions(sms, tipus)
{
\t $("#warningboxes").toggleClass(tipus); \t // Add class
\t $('#warningboxes').css('visibility','visible').hide(); \t \t // start hidden to fadein
\t $("#warningboxes").html(sms); // add message in div
\t $("#warningboxes").fadeIn(1500, function() // show up
\t \t {
\t \t \t setTimeout(function()
\t \t \t {
\t \t \t \t $('#warningboxes').fadeOut(1500, 0); // dissapears but removes space of div #warningboxes; with fadeto(), fadein won't work anymore
\t \t \t }, 1500)
\t \t \t
\t \t \t
\t \t \t setTimeout(function()
\t \t \t {
\t \t \t \t BackToStd(tipus); // remove the properties added so it still works
\t \t \t \t
\t \t \t }, 3000);
\t \t } \t \t \t
\t);
}
function BackToStd(tipus)
{
\t $('#warningboxes').toggleClass(tipus);
\t $('#warningboxes').css(
\t \t {
\t \t \t display: "block",
\t \t \t opacity: "",
\t \t \t filter: "",
\t \t \t zoom: "",
\t \t \t visibility: ""
\t \t }
\t);
}
.warningboxes
{
\t border: 1px solid;
\t margin: 10px 0px;
\t padding:15px 10px 15px 50px;
\t background-repeat: no-repeat;
\t background-position: 10px center;
\t visibility:hidden;
\t display:block;
}
.info
{
\t color: #00529B;
\t background-color: #BDE5F8;
\t background-image: url('../res/PNGICONS/KnobInfo.png');
}
.success
{
\t color: #4F8A10;
\t background-color: #DFF2BF;
\t background-image: url('../res/PNGICONS/KnobValidGreen.png');
}
.warning
{
\t color: #9F6000;
\t background-color: #FEEFB3;
\t background-image: url('../res/PNGICONS/KnobAttention.png');
}
.error
{
\t color: #D8000C;
\t background-color: #FFBABA;
\t background-image: url('../res/PNGICONS/KnobCancel.png');
}
<body>
\t <div class="warningboxes" id ="warningboxes" name="warningboxes"> Info message</div>
\t <table id="myid">
....
....
...
<img src='./res/edit.png' id='imagenok4' class='deleteAndOthers' OnClick='edit(4)'>
<img src='./res/edit.png' id='imagenok5' class='deleteAndOthers' OnClick='edit(5)'>
<img src='./res/edit.png' id='imagenok6' class='deleteAndOthers' OnClick='edit(6)'>
....
... 어디 fadein I 및 페이드 아웃으로 여기
function Actions(sms, tipus)
입니다.
고맙습니다!
는 동일하지만 그것을 볼 만들기 다음 숨겨진 시작하고 어떻게해야합니까 ... 좋은 보이지만 그것을 밖으로 정렬 할 수 없습니다 아직? visible-> hidden-> visible 대신에? 감사. 잠깐, 내가 가지고 있다고 생각하고, 좀 더 시험을 봐야 해. 방금 귀하의 답변을 보았습니다 (귀하가 업데이트하려고합니다). 다시 한 번 감사드립니다! –
이 코드를 업데이트하겠습니다. –
감사합니다. 매우 유용합니다! –