这是可能不使用javascript?

编程入门 行业动态 更新时间:2024-10-28 10:35:10
本文介绍了这是可能不使用javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用JSFiddle创建了一个简单的网络用户界面,我想知道是否可以不使用JavaScript 创建相同的用户界面。

I made a simple web UI with JSFiddle and I am wondering if the same UI can be made without using JavaScript.

一个小提琴说超过1000个字。

A Fiddle says more than 1000 words.

问题是(因为某些人似乎不太清楚):如何在不使用任何JavaScript的情况下实现相同的结果?

So the question is (because it seems unclear for some people): How can I achieve the same results without using any JavaScript?

不想使用JavaScript重新计算每个滚动事件的位置,因为IE中的重新定位不够流畅。

PS: I don't want to use JavaScript to re-calculate the position on every scroll event because the repositioning in IE is not smooth enough.

HTML:

<div class="A"> <div class="B"> B </div> <div class="C"> This stays fixed when scrolling horizontally, but scrolls along when scrolling down the parent. </div> </div>

CSS:

.A { background-color: yellow; height: 400px; width: 700px; overflow:scroll; position: relative; } .B { background-color: green; height: 1000px; width: 1500px; position: absolute; top:0; color:white; } .C { background-color: red; position: absolute; left: 100px; top: 0px; height: 1000px; width: 100px; }

JS(使用jQuery):

JS (with jQuery):

$('.A').scroll(function(e) { $('.C').css('left', e.target.scrollLeft + 100); });

推荐答案

当足够的浏览器支持它时,请使用新的 粘性位置值:

When enough browsers support it, you will be able to use the new sticky position value:

.C { position: sticky; position: -webkit-sticky; left: 100px; top: auto; /* Default value */ }

jsfiddle/5z3nLqq5/12/

更多推荐

这是可能不使用javascript?

本文发布于:2023-08-04 03:25:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1292454.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:这是   能不   javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!