``position:fixed`是否有问题?

时间:2016-06-02 06:56:46

标签: html css css-position absolute document-body

在用于移动设备和桌面浏览器的SPA上,我需要在position: fixed上设置<body>以避免iOS溢出/橡皮圈滚动。

position: fixed并且对<body>的修改总是有些麻烦且有风险导致问题。

这就是我想澄清的原因:

是否有任何已知的问题/警告/注意事项(即堆叠上下文,z-indexing上下文,儿童的静态/相对/绝对/固定定位)/ ...添加{{1}时} position: fixed

1 个答案:

答案 0 :(得分:1)

&#34;位置:固定&#34;涉及一个&#34;元素&#34;相对于浏览器窗口定位。网页浏览器缩放受其影响。 IE6及以下版本也将打​​破它。

也许会更好:

# dput(Sample)

structure(list(Year = c(2011, 2011, 2011, 2011, 2011, 2012, 2012, 
2012, 2012, 2012, 2013, 2013, 2013, 2013, 2013, 2014, 2014, 2014, 
2014, 2014, 2015, 2015, 2015, 2015, 2015), Person = c("A", "B", 
"C", "D", "E", "A", "B", "C", "D", "E", "A", "B", "C", "D", "E", 
"A", "B", "C", "D", "E", "A", "B", "C", "D", "E"), 
'Mean of Ice-cream units per day' = c(45, 
40, 35, 55, 65, 57, 49, 45, 32, 27, 85, 79, 85, 48, 35, 15, 6, 
99, 45, 47, 49, 85, 35, 66, 99)), class = c("tbl_df", "tbl", 
"data.frame"), row.names = c(NA, -25L), .Names = c("Year", "Person", 
"Mean of Ice-cream units per day"))

然后是html:

html, body { height: 100%; overflow: auto; }

body .element { position:fixed; bottom: 0; }