Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
147 views
in Technique[技术] by (71.8m points)

javascript - How do I achieve navigating effect within a view in HTML/JS/CSS?

I wonder how do I make an audience feel like navigating a single page and zoom in/out like the link below.

https://pudding.cool/2017/09/hip-hop-words/

I looked into inspector's css and it uses background-posiiton which I haven't used? It might have something to do with this attribute I guess?

But not sure what makes the page feel like i'm actually zooming in the page.

before zoom enter image description here

after zoom enter image description here

question from:https://stackoverflow.com/questions/65849091/how-do-i-achieve-navigating-effect-within-a-view-in-html-js-css

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Maybe this helps: (it does not zoom, but it scrolls the paper so the the clicked portrait is centered)

var portrait = $(".portrait");
var paper = $("#paper");

portrait.click(function(e) {
    var myleft=200-$(this).position().left;
  paper.css({left: myleft})
})
#paper {width: 300px; height: 300px; border: 1px solid blue; position: absolute; left: 200px;}

.portrait { width: 20px; height: 20px; border: 1px dotted pink; position: relative}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="paper">
  <div class="portrait" style="left: 50px; top: 100px">
  :-)
  </div>
  
    <div class="portrait"  style="left: 200px; top: 100px">
  :-(
  </div>
  
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...