我有一个我制作的SVG的页脚/行,但它们在第一部分和第二部分之间的过渡期间无法显示动画。代码不容易调试,因为这需要通过js控制一些元素的大小来实现动画效果。:许多勇敢的用户已经想出了在Chrome和火狐上都能用的解决方案,但要想获得赞誉,这个解决方案必须在上也能用。
我已经验证了我在转换期间添加的类(.fixed
)确实被应用了,因为我使用它们来改变SVG的大小。因此,当SVG改变大小时,由于某些原因,我仍然不能让CSS转换为动画。您可以在下面的GIF中查看此故障的动画。
页脚没有动画效果:
我认为需要转换代码的元素是SVG本身,它们属于areaSVG
类,因为它们是从max-height: 18vh
更改为max-height: 9vh.
的元素。但是,当我向.areaSVG
添加一些动画代码时,它不起作用,所以可能我错了。以下是我尝试添加到初始SVG (.areaSVG
)设置的转换代码,但失败了:
-webkit-transition: max-height 1s;
-moz-transition: max-height 1s;
transition: max-height 1s;
几个月前,在另一位更有经验的程序员的帮助下,我添加了一个javscript函数,它在某种程度上为SVG提供了动画效果。我们使用JS调用window.requestAnimationFrame(startAnimation)
,但它不再起作用。我注释了与此相关的部分,但如果您认为需要使用JS来实现动画效果,请随意使用代码笔。一个合适的答案应该能让动画在,Chrome和Firefox.中工作。
Codepens
这是您应该使用的最简单、最小的版本,因为它没有媒体查询(根据@Eric N
http://codepen.io/ihatecoding/pen/LREOPW
选择器
第一部分的选择器(在页面顶部):
父级SVG整个页脚:#indexFooter
.ey-col-svg
.areaSVG
第二部分的选择器(向下滚动100px后):
固定整个固定页脚:#indexFooter.fixed
.ey-col-svg.fixed
.areaSVG.fixed
注意:当页面第一次加载时,SVG父(.ey-col-svg
)和SVG本身的(.areaSVG
)都是不可见的,并且设置了display:none
,以避免给用户带来奇怪的体验。
以下是关于每个部分中重要元素的信息:
大页脚(在第一部分)
最初的CSS (第一部分)
/* The whole footer container */
#indexFooter {
text-align: center;
box-sizing: border-box;
position: fixed;
vertical-align: middle;
bottom: 0;
left: 0;
z-index: 5000;
max-height: 33.33vh;
width: 100%;
}
/* The SVG container*/
.ey-col-svg {
display: none;
height: auto;
text-align: center;
box-sizing: border-box;
padding: 0;
}
/* The SVG */
.areaSVG {
display: none;
max-height: 18vh;
box-sizing: content-box;
margin: 0;
}
接下来,JS运行,然后显示元素(仍在第一部分):
/* The SVG container*/
.ey-col-svg {
display: block;
}
/* The SVG*/
.areaSVG {
display: inline-block;
}
小页脚(在第一部分下方)
离开第一部分后(页脚应较小且固定)
/* The SVG when low on page*/
.areaSVG.fixed {
max-height: 9vh;
}
Javascript/jQuery
这是Javascript,如果你想看的话
$(document).ready(function() {
var sectionIndex = 1;
var animationName = 'indexAnimateLand';
startAnimation(); //includes resizing background image and resizing svgs
toggleIntroClass(); //adds css depending on section of page
// if the user resizes the window, run the animation again,
// and resize the landing
$(window).on('resize', function(){
startAnimation();
resizeLanding();
});
//sizes the landing image and the icons
function startAnimation() {
$('.ey-col-svg').css('display', 'block');
$('.areaSVG').css('display', 'inline-block');
resizeLanding(); // resize the background image
// window.requestAnimationFrame(startAnimation); //animate
} // end start Animation
//resizes the landing image and sets top margin for the following section
function resizeLanding() {
var $lndFooter = $('#indexFooter');
var $bgLand = $('#section0img');
var $contactSection = $('#section2Div');
var winHeight = $(window).height();
var lndFooterHeight = $lndFooter.height();
bgFinalHeight = winHeight - lndFooterHeight;
$bgLand.css("height", bgFinalHeight);
$contactSection.css("margin-top", bgFinalHeight);
}
// changes the .css classes depending on section,
//(also triggers landing image resize if necessary)
function toggleIntroClass(){
var winHeight = $(window).height();
var heightThreshold = $("#section0").offset().top;
var heightThreshold_end = $("#section0").offset().top + $("#section0").height();
$(window).scroll(function() {
var scroll = $(window).scrollTop();
//if user hasn't scrolled past 100px/the first section, adjust classes
if (scroll <= 100)
// (scroll >= heightThreshold && scroll < heightThreshold_end )
{
sectionIndex = 1;
$('#newHeader').removeClass('fixed');
$('#nameBoxIndexTop').removeClass('fixed');
$('#indexIconsContainer').removeClass('fixed');
$('#indexIconsList').removeClass('fixed');
$('#linkCell').removeClass('fixed');
$('#indexFooter').removeClass('fixed');
$('.ey-text-content').removeClass('fixed');
$('.ey-col-svg').removeClass('fixed');
$('.ey-col-1').removeClass('fixed');
$('.ey-row-scale').removeClass('fixed');
$('.ey-nav-bar').removeClass('fixed');
$('.areaSVG').attr("class", "areaSVG");
}
//else if they have scrolled past the first hundred pixels/first section, adjust classes
else {
sectionIndex = 2;
$('#newHeader').addClass('fixed');
$('#nameBoxIndexTop').addClass('fixed');
$('#indexIconsContainer').addClass('fixed');
$('#indexIconsList').addClass('fixed');
$('#linkCell').addClass('fixed');
$('#indexFooter').addClass('fixed');
$('.ey-text-content').addClass('fixed');
$('.ey-col-svg').addClass('fixed');
$('.ey-col-1').addClass('fixed');
$('.ey-row-scale').addClass('fixed');
$('.ey-nav-bar').addClass('fixed');
$('.areaSVG').attr("class", "areaSVG fixed");
}
}); //end inner scroll Function
};//end intro Class toggle function
});//end document ready
任何帮助都将不胜感激!谢谢!
发布于 2016-10-18 02:33:33
我这里有一个跨浏览器的解决方案:http://codepen.io/anon/pen/EgZzxo
它并不完美:有一些关于改变宽度的问题,但我相信你发布的问题已经得到了回答。要修复其他问题,您必须查看您的css
,以查看某些元素是否没有更改display
属性-这可能会扰乱您的转换。此外,固定宽度应该会有所帮助,这样它们就不会依赖于文本大小-当文本变小时,宽度会发生变化,因此其他元素的位置也会随之变化。
你遇到的主要问题是.ey-row-scale.fixed
有display: inline-block
,而.ey-row.scale
没有,这是破坏过渡的一件事。另一个是必须在svg
元素上定义转换,所以不是:
.indexAnimateLand {
}
我不得不这样做:
.indexAnimateLand svg {
}
然后它成功了。不确定确切的原因,但可能是内联svg没有正确继承样式。
我还向文本元素添加了过渡,并且必须解开您放入其中的一些!important
边距。
一般来说,代码可以在以下几个方面进行改进:
.fixed
类时,很容易看出有什么不同。font-size
不应该在vh
中定义,因为这是相对于屏幕大小的,并且可以节省文本unreadable!important
,或者更好的是,根本不使用它。通常,如果您修复了迫使您首先使用!important
的问题(),那么代码可能会更加整洁。
发布于 2016-10-16 04:07:54
我想我对导航菜单的动画做了一些很好的处理。
我做的第一件事就是清除所有看起来没有用过的代码……显然是因为之前的多次尝试。
删除未使用的CSS类和未使用的js类可以“减少”行数。
我还用更有意义的名称重命名了一些剩余的类...
因为我迷路了。
我设法修复了动画的“跳跃效果”(我在评论中从开始),使移动看起来非常流畅。我主要是用CSS完成的。
结果
完美的结果:
眼睛图标位于屏幕下方30%的位置:
(但可能看起来像是故意的!)
适用于Windows5.1.7的
我无法在Safari10上测试它,因为我没有任何苹果device.
非常细微的背景图像的“跳跃”效果:
(当动画触发时)
动画中不好的奇怪之处:
(但最小化和扩展状态都可以)
适用于不支持视口单位(vh、vw等)的浏览器就像windows和三星浏览器上的Safari一样,我发现CSS polyfill的“几乎”做到了这一点。它不是完美的,但非常接近。
其他浏览器support viewport units,包括IOS Safari10。
注意到在控制台中抛出了Saabi抛出的错误,我没有修复这些错误。
我认为结果是Saabi不能完全解析CSS文件。
但由于它几乎修复了一些浏览器,而不影响其他浏览器(Saabi仅在浏览器不支持视口单元时运行)……这是值得的。
我在我的服务器上使用它,但不能在CodePen上使用,因为我没有找到CDN。
关于IE...
问题来自于其他没有(或不好)支持的东西...
我不知道是什么。
CSS检查器中的SVG有一些小问题。
由于这一点,在W3C markup validator中也有。
我建议你从你的创建PNG来消除这些错误。
这些错误可能是Safari for Windows和Samsung浏览器上剩余显示问题的原因。Saabi发现了一些东西..。我想这可能是你的“眼睛图标”SVG。
请随时询问我所做的任何更改。
;)
HTML
<div id="whole">
<div id="nav-panel" class="indexRow minimise-smooter">
<!-- fancy icon footer -->
<div id="nav-title" class="indexRow minimise-smooter">
LINKS
</div>
<div class="nav-eyes minimise-smooter indexRow">
<div class="indexAnimateLand indexRow">
<div class="eye-outer-div indexRow">
<a class="eSVG areaAnchor indexRow" href="e.html">
<div class="eye-inner-div indexRow">
<svg class="SVG" x="0px" y="0px" viewBox="0 0 80 80" perserveAspectRatio="xMidYMid meet" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="f1" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceAlpha" dx="3" dy="3" ></feOffset>
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="2" ></feGaussianBlur>
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" ></feBlend>
</filter>
</defs><path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d="
M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381
C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" filter="url(#f1)" ></path>
<path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75
C12.787,37.379,11.41,38.895,11.41,38.895z" ></path>
<ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" ></ellipse>
<ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" ></ellipse>
<path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393
c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456
c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558
c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" ></path>
</svg>
</div>
<div class="eye-text indexRow minimise-smooter">LINK 1</div>
</a>
</div>
<div class="eye-outer-div indexRow">
<a class="eSVG areaAnchor indexRow" href="e.html">
<div class="eye-inner-div indexRow">
<svg class="SVG" x="0px" y="0px" viewBox="0 0 80 80" perserveAspectRatio="xMidYMid meet" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="f1" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceAlpha" dx="3" dy="3" ></feOffset>
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="2" ></feGaussianBlur>
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" ></feBlend>
</filter>
</defs><path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d="
M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381
C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" filter="url(#f1)" ></path>
<path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75
C12.787,37.379,11.41,38.895,11.41,38.895z" ></path>
<ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" ></ellipse>
<ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" ></ellipse>
<path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393
c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456
c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558
c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" ></path>
</svg>
</div>
<div class="eye-text indexRow minimise-smooter">LINK 2</div>
</a>
</div>
<div class="eye-outer-div indexRow">
<a class="eSVG areaAnchor indexRow" href="e.html">
<div class="eye-inner-div indexRow">
<svg class="SVG" x="0px" y="0px" viewBox="0 0 80 80" perserveAspectRatio="xMidYMid meet" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="f1" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceAlpha" dx="3" dy="3" ></feOffset>
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="2" ></feGaussianBlur>
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" ></feBlend>
</filter>
</defs><path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d="
M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381
C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" filter="url(#f1)" ></path>
<path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75
C12.787,37.379,11.41,38.895,11.41,38.895z" ></path>
<ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" ></ellipse>
<ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" ></ellipse>
<path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393
c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456
c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558
c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" ></path>
</svg>
</div>
<div class="eye-text indexRow minimise-smooter">LINK 3</div>
</a>
</div>
<div class="eye-outer-div indexRow">
<a class="eSVG areaAnchor indexRow" href="e.html">
<div class="eye-inner-div indexRow">
<svg class="SVG" x="0px" y="0px" viewBox="0 0 80 80" perserveAspectRatio="xMidYMid meet" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="f1" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceAlpha" dx="3" dy="3" ></feOffset>
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="2" ></feGaussianBlur>
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" ></feBlend>
</filter>
</defs><path id="circle-background" opacity="0.4196" fill="#FFFFFF" enable-background="new " d="
M4.193,37.492c0-18.987,15.419-34.38,34.44-34.38c19.021,0,34.439,15.393,34.439,34.38c0,18.987-15.418,34.381-34.439,34.381
C19.613,71.873,4.193,56.48,4.193,37.492L4.193,37.492z" filter="url(#f1)" ></path>
<path id="sclera" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M11.41,38.895c27.619-31.029,41.313-9.542,49.646-2.012c-4.306,6.07-12.69,27.49-46.392,9.919c0,0-5.375-3.548-5.641-4.75
C12.787,37.379,11.41,38.895,11.41,38.895z" ></path>
<ellipse id="iris" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" cx="38.196" cy="36.63" rx="16.202" ry="15.686" ></ellipse>
<ellipse id="pupil" class="fillWhite" fill-rule="evenodd" clip-rule="evenodd" cx="38.529" cy="36.954" rx="5.628" ry="5.449" ></ellipse>
<path id="eyelid" class="fillDark" fill-rule="evenodd" clip-rule="evenodd" stroke-width="0.25" stroke-miterlimit="8" d="
M56.955,26.227c5.438,2.787,12.803,9.595,12.803,9.595s-2.338,3.235-5.677,2.588c-4.027,3.396-13.345,29.705-49.417,8.393
c33.702,17.571,42.086-3.849,46.392-9.919c-8.333-7.53-22.026-29.018-49.646,2.012c0,0-2.94,1.806-4.112-1.456
c-1.172-3.261,2.481-0.477,4.009-2.911c1.527-2.434,3.674-3.557,7.682-6.792c-4.008,0.646-7.348,3.558-7.348,3.558
c10.521-10.835,31.379-17.498,53.107-4.205C64.748,27.089,59.404,26.119,56.955,26.227z" ></path>
</svg>
</div>
<div class="eye-text indexRow minimise-smooter">LINK 4</div>
</a>
</div>
</div>
</div>
</div>
<div id="fullpage">
<article>
<section id="section0">
<!-- content inside of landing section (except for icons) -->
<div id="section0img">
</div>
</section>
<section id="section2">
<div id="section2Div">
<h1><a id="contact">Section 2</a></h1>
</div>
</section>
<section id="section3">
<h1>Section 3</h1>
</section>
</article>
</div>
</div>
和要添加的零件,以使用polyfill
(就在</body>
__上方)
<!-- Saabi -->
<div id="viewport-unit-tester" style="opacity:0; height:1px; width:50vw;"></div>
<script>
// test if the browser can handle viewport unit.
// If not, it load Saabi, a polyfill CSS viewport unit.
var elem = document.getElementById("viewport-unit-tester");
var width = parseInt(window.innerWidth / 2, 10);
var compStyle = parseInt((window.getComputedStyle ?
getComputedStyle(elem, null) :
elem.currentStyle).width, 10);
//console.log(width);
//console.log(compStyle);
if(!width==compStyle){
console.log("This browser doesn't support viewport units.");
}else{
console.log("This browser supports viewport units.");
}
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp*/)
{
var len = this.length;
if (typeof fun != "function")
throw new TypeError();
var res = new Array();
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this)
{
var val = this[i]; // in case fun mutates this
if (fun.call(thisp, val, i, this))
res.push(val);
}
}
return res;
};
}
</script>
<script src="saabi/tokenizer.js"></script>
<script src="saabi/parser.js"></script>
<script src="saabi/vminpoly.js"></script>
jQuery / JavaScript
$(document).ready(function() {
var sectionIndex = 1;
startAnimation(); //includes resizing background image and resizing svgs
toggleIntroClass(); //adds css depending on section of page
// if the user resizes the window, run the animation again, and resize the landing
$(window).on('resize', function(){
startAnimation();
});
//sizes the landing image and the icons
function startAnimation() {
$('.eye-inner-div').css('display', 'block');
$('.SVG').css('display', 'inline-block');
}
// changes the .css classes depending on section,
//(also triggers landing image resize if necessary)
function toggleIntroClass(){
$(window).scroll(function() {
var scroll = $(window).scrollTop();
//if user hasn't scrolled past 100px/the first section, adjust classes
if (scroll <= 100) {
sectionIndex = 1;
$('#nav-title').removeClass('minimised');
$('#nav-panel').removeClass('minimised');
$('.eye-text').removeClass('minimised');
$('.eye-inner-div').removeClass('minimised');
$('.eye-outer-div').removeClass('minimised');
$('.nav-eyes').removeClass('minimised');
$('.SVG').attr("class", "SVG");
}
//else if they have scrolled past the first hundred pixels/first section, adjust classes
else {
sectionIndex = 2;
$('#nav-title').addClass('minimised');
$('#nav-panel').addClass('minimised');
$('.eye-text').addClass('minimised');
$('.eye-inner-div').addClass('minimised');
$('.eye-outer-div').addClass('minimised');
$('.nav-eyes').addClass('minimised');
$('.SVG').attr("class", "SVG minimised");
}
}); //end inner scroll Function
}//end intro Class toggle function
});//end document ready
CSS
* {
padding: 0;
margin: 0;
}
html,
body {
margin: 0;
padding: 0;
height: auto;
border: none;
font-size: 100%;
}
h1 {
text-align: center;
font-size: 10vh;
font-family: sans-serif;
}
/* ------------------------------------------------------------------------------------------------------------------------- Main sections */
#section0 {
height:100vh;
}
#section2 {
height:100vh;
background-color:red;
}
#section3 {
height:100vh;
background-color:yellow;
}
#section0img {
background: url('https://cdn.pbrd.co/images/cZIoMIenr.png') no-repeat;
-webkit-background-size: 100vw 100vh;
-moz-background-size: 100vw 100vh;
-o-background-size: 100vw 100vh;
background-size: 100vw 100vh;
height:100vh;
}
/* ------------------------------------------------------------------------------------------------------------------------- Navigation panel */
#nav-panel {
text-align: center;
box-sizing: border-box;
position: fixed;
vertical-align: middle;
bottom: 0;
left: 0;
z-index: 500;
max-height: 33.33vh;
width: 100%;
border-top: 0.5vh solid Gray;
border-bottom: 0.5vh solid Gray;
}
.nav-eyes {
width: 100% !important;
max-height: 33.33vh;
overflow: hidden;
text-align: center;
}
.indexRow {
background-color: #FBFBFA;
}
#nav-title {
max-height: 3.33vh;
line-height: 3.33vh;
font-size: 3.33vh;
padding: 2vh;
}
.areaAnchor {
text-decoration: none !important;
text-align: center;
}
.eye-text {
text-rendering: optimizeLegibility;
display: block;
text-align: center;
white-space: nowrap;
max-height: 8vh;
line-height: 3.5vh;
color: black;
z-index: 100;
font-size: 4vh;
margin: 3vh 0 .5vh 0 !important;
}
/* ------------------------------------------------------------------------------------------------------------------------- SVG icons */
.eye-outer-div {
text-align: center !important;
width: 20%;
/*height: 100%;*/
margin: 0;
padding: 0;
display: inline-block;
}
.eye-inner-div {
display: none;
height: auto;
text-align: center;
box-sizing: border-box;
padding: 0;
}
.SVG {
display:none;
max-height: 18vh;
box-sizing: content-box;
margin: 0;
-webkit-animation: SVG 1s forwards;
animation: SVG 1s forwards;
}
@-webkit-keyframes SVG {
100% {
max-height: 18vh;
}
0% {
max-height: 9vh;
}
}
@keyframes SVG {
100% {
max-height: 18vh;
}
0% {
max-height: 9vh;
}
}
/* ------------------------------------------------------------------------------------------------------------------------- minimised */
#nav-panel.minimised {
border-top: 0px solid Gray;
border-bottom: 0px solid Gray;
}
#nav-title.minimised { /* SAME AS .eye-text.minimised */
max-height: 0;
font-size: 0;
color: red;
margin: 0;
padding: 0;
line-height: 0;
}
.nav-eyes.minimised {
max-height: 9vh;
}
.eye-outer-div.minimised {
width: 20%;
max-height:9vh;
padding: 0;
margin: 0;
display: inline-block;
float: none;
/* box-sizing: border-box; */
}
.eye-text.minimised{
max-height: 0;
font-size: 0;
color: red;
margin: 0;
padding: 0;
line-height:0;
}
.SVG.minimised {
-webkit-animation: SVGFixed 1s forwards;
animation: SVGFixed 1s forwards;
}
@-webkit-keyframes SVGFixed {
0% {
max-height: 18vh;
}
100% {
max-height: 9vh;
}
}
@keyframes SVGFixed {
0% {
max-height: 18vh;
}
100% {
max-height: 9vh;
}
}
.minimise-smooter{
-webkit-transition-property: line-height, font-size, max-height, color, padding, margin, border-bottom, border-top;
-moz-transition-property: line-height, font-size, max-height, color, padding, margin, border-bottom, border-top;
-o-transition-property: line-height, font-size, max-height, color, padding, margin, border-bottom, border-top;
transition-property: line-height, font-size, max-height, color, padding, margin, border-bottom, border-top;
-webkit-transition-duration: 1s;
-moz-transition-duration: 1s;
-o-transition-duration: 1s;
transition-duration: 1s;
}
/* ------------------------------------------------------------------------------------------------------------------------- END of minimised */
/* ------------------------------------------------------------------------------------------------------------------------- SVG formatting for the eyes*/
#circle-background {
-moz-filter: box-shadow(3px 3px 2px rgba(0, 0, 0, 0.5));
-webkit-filter: box-shadow(3px 3px 2px rgba(0, 0, 0, 0.5));
filter: box-shadow(3px 3px 2px rgb(0, 0, 0, 0.5));
fill: Gainsboro;
}
.fillDark {
fill: #939598;
}
.fillWhite {
fill: White;
}
.active #circle-background-e,
.active #sclera,
.active #pupil {
fill: rgb(183, 36, 103);
}
.active #eyelid,
.active #iris {
stroke: rgb(183, 36, 103);
}
.active #eyelid,
.active #iris {
fill: white;
}
.active #circle-background-s {
fill: rgb(82, 79, 161);
}
.eSVG #pupil {
fill: Black;
}
发布于 2016-10-18 03:20:26
http://codepen.io/stephendesjardins/pen/wzEVrQ
.ey-col-svg {
height: auto;
text-align: center;
box-sizing: border-box;
padding: 0;
position:relative;
height:100px;
transition:height 0.3s;
}
.fixed .ey-col-svg {
height:50px;
}
.fixed .ey-text-content {
display:none;
}
/*this is the container for the bottom svg */
.areaSVG {
box-sizing: content-box;
margin: 0;
position:absolute;
height:100%;
width:100%;
z-index:10;
left:0;
top:0;
}
您可以对其进行调整,但这里是它的要点。不是在svg上做过渡高度,而是在父div上做。此外,只需在其上添加一个高度,并将您的svg绝对放在其中。我不明白为什么这对于max-height来说应该是动态的。在此特定示例中,图标和文本永远不会超过更高的高度。
我希望这能有所帮助。
https://stackoverflow.com/questions/39322082
复制相似问题