약 180px의 꽤 큰 헤더가있는 웹 페이지에서 작업하고 있습니다. 더 나은 사용자 경험을 위해 사용자가 스크롤을 시작하면 헤더 크기를 약 100px로 줄이기 위해 모든 것이 원활하게 진행되고 있지만 로고 크기를 줄이기 위해 로고를 가져올 수 없습니다. 헤더를 잘 만들거나 적어도 배경 크기, 아이디어는 없습니까?스크롤 후 헤더 높이 줄이기
코드는 다음과 같이 -
<script>
$(function(){
$('#header').data('size','big');
});
$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
if($('#header').data('size') == 'big')
{
$('#header').data('size','small');
$('#header').stop().animate({
height:'100px'
},600);
}
}
else
{
if($('#header').data('size') == 'small')
{
$('#header').data('size','big');
$('#header').stop().animate({
height:'180px'
},600);
}
}
});$(function(){
$('#header').data('size','big');
});
$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
if($('#header').data('size') == 'big')
{
$('#header').data('size','small');
$('#header').stop().animate({
height:'100px'
},600);
}
}
else
{
if($('#header').data('size') == 'small')
{
$('#header').data('size','big');
$('#header').stop().animate({
height:'180px'
},600);
}
}
});
</script>
<script>
$(function(){
$('#logo').data('size','big');
});
$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
if($('#logo').data('size') == 'big')
{
$('#logo').data('size','small');
$('#logo').stop().animate({
width:'59px',height:'63px'
},600);
}
}
else
{
if($('#logo').data('size') == 'small')
{
$('#logo').data('size','big');
$('#logo').stop().animate({
width:'128px',height:'120px'
},600);
}
}
});$(function(){
$('#logo').data('size','big');
});
$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
if($('#logo').data('size') == 'big')
{
$('#logo').data('size','small');
$('#logo').stop().animate({
width:'59px',height:'63px'
},600);
}
}
else
{
if($('#logo').data('size') == 'small')
{
$('#logo').data('size','big');
$('#logo').stop().animate({
width:'128px',height:'120px'
},600);
}
}
});
</script>
"크기를 줄이기 위해 로고를 얻을 수없는 것"이라는 의미는 무엇입니까? 헤더는 줄어 듭니다. 바이올린을 제공 할 수 있습니까? – LcSalazar
HTML 코드를 삽입하여 붙여 넣기하십시오. –
내 머리글이 크기가 줄어들지 만 어떤 이유로 jsfiddle에서 작동하지 않지만 문제는 크기가 줄인 로고입니다. 그러나 배경 크기가 잘리지 않는 로고를 남기지 않는 것으로 보입니다. 나는 원래의 질문에 바이올린을 추가 할 것이다. @LcSalazar – user3357728