我正在試圖製作一個類似谷歌地圖的系統,用平移和縮放div的內容。這個div將有不同的按鈕,鏈接和圖像。我只是無法找到一種方法來做到這一點,而不使用畫布。任何想法如何做到這一點? 「zoomTarget」上點擊時是否可以放大和縮小div的內容?
0
A
回答
1
您可以通過Zoomooz.js
做這隻需添加到您想放大的元素:
<div class=""zoomTarget">This element zooms when clicked on.</div>
您還可以添加一些額外的屬性來調整動畫作爲元素的數據字段:從源
<div class="zoomTarget" data-targetsize=lass="0.45" data-duration="600">This element zooms when clicked on.</div>
0
我已經使用參考文獻 (https://rbalajiprasad.blogspot.in/2012/02/zoom-in-zoom-out-jquery.html)創建了縮小div (http://jsfiddle.net/tamilselvanA/05erzotj/5/)的簡單縮放。
$(document).ready(function() {
var currZoom = $("#divpnlChart").css("zoom");
if (currZoom == 'normal') currZoom = 1;
$(".zoomIn").click(function() {
currZoom *= 1.2;
$("#divpnlChart").css("zoom", currZoom);
$("#divpnlChart").css("-moz-transform", "Scale(" + currZoom + ")");
$("#divpnlChart").css("-moz-transform-origin", "0 0");
});
$(".zoomOff").click(function() {
$("#divpnlChart").css("zoom", 1);
$("#divpnlChart").css("-moz-transform", "Scale(" + currZoom + ")");
$("#divpnlChart").css("-moz-transform-origin", "0 0");
});
$(".zoomOut").click(function() {
currZoom *= .8;
$("#divpnlChart").css("zoom", currZoom);
$("#divpnlChart").css("-moz-transform", "Scale(" + currZoom + ")");
$("#divpnlChart").css("-moz-transform-origin", "0 0");
});
});
var down = false;
var scrollLeft = 0;
var x = 0;
$('#sd').mousedown(function(e) {
down = true;
scrollLeft = this.scrollLeft;
x = e.clientX;
}).mouseup(function() {
down = false;
}).mousemove(function(e) {
if (down) {
this.scrollLeft = scrollLeft + x - e.clientX;
}
}).mouseleave(function() {
down = false;
});
#sd {
border: 1px solid black;
height: 1200px;
margin: 50px auto;
overflow: scroll;
width: 500px;
}
#divpnlChart {
height: 100px;
width: 900px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="zoomIn" style="font-size:200%">+</span>
<br>
<span class="zoomOff">original</span>
<br>
<span class="zoomOut" style="font-size:250%">-</span>
<br>
<div id="sd">
<div id="divpnlChart" style="float: left; width: 85%;">
<div class="Normal">
CHENNAI: Actor <a class="key_underline" href="https://timesofindia.indiatimes.com/topic/Kamal-Haasan" pg="AS1_InlineMedia#AS1_https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms~Kamal Haasan-https://timesofindia.indiatimes.com/topic/Kamal-Haasan">Kamal Haasan</a> has alleged that <a class="key_underline" href="https://timesofindia.indiatimes.com/topic/right-wing-Hindus" pg="AS1_InlineMedia#AS1_https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms~right wing Hindus-https://timesofindia.indiatimes.com/topic/right-wing-Hindus">right wing Hindus</a> have started employing terrorism to propagate their communal agenda.
<br>
<br>
In his column in a Tamil magazine that hit stands on Thursday, the 62-year-old actor said the right-wingers could no longer say "show me a Hindu terrorist if you can." Terrorism has spread into their fold also, he said.
<br>
<br>
"Earlier, the right-wing <a class="key_underline" href="https://timesofindia.indiatimes.com/topic/Hindus" pg="AS1_InlineMedia#AS1_https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms~Hindus-https://timesofindia.indiatimes.com/topic/Hindus">Hindus</a> employed debates, and not force, against people of other religions. Having realised that their attempts are failing, they have started using violence," he wrote.
<br>
<br>
"This is not a victory or a sign of progress. If we start believing that force will prevail and not truth, then we will all turn into violent beasts," he wrote.
<br>
<br>
In his column, Kamal was replying to a question posed by <a class="key_underline" href="https://timesofindia.indiatimes.com/india/kerala" pg="AS1_InlineMedia#AS1_https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms~Kerala-https://timesofindia.indiatimes.com/india/kerala">Kerala</a> chief minister <a class="key_underline" href="https://timesofindia.indiatimes.com/topic/Pinarayi-Vijayan" pg="AS1_InlineMedia#AS1_https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms~Pinarayi Vijayan-https://timesofindia.indiatimes.com/topic/Pinarayi-Vijayan">Pinarayi Vijayan</a> who had sought the actor's opinion on "the attempt by Hindutva forces to infiltrate into <a class="key_underline" href="https://timesofindia.indiatimes.com/india/tamil-nadu" pg="AS1_InlineMedia#AS1_https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms~Tamil Nadu-https://timesofindia.indiatimes.com/india/tamil-nadu">Tamil Nadu</a>."
<br>
<br>
Kamal wrote: "Only change is permanent. No matter how many forces push it back, Tamil Nadu will once again prevail as the forerunner in social reforms. Kerala is standing as an example today. Congrats for that."
<br>
<div class="last8brdiv"><div class="sponsor_block clearfix loaded" style="display: none;"><ul class="colombiaSuccess " id="129146-614536721" data-skew="0" data-ad-size="[0,370]" data-expansion-size="[0,480]" data-adwidth="640" data-adheight="360" data-loop="0" data-cb="processCtnAds" data-callback="sponsorAdSuccess" data-position="614536721" data-slot="129146" data-autoplay="false" data-native-vid-tmpl="ctn_belly_vid" data-native-tmpl="ctn_midarticle" data-desc-len="90" style="display: block; width: 100%;"><li><a href="https://ade.clmbtech.com/evnt/click.htm?r=MjExMTI4YjYtZGUwOS00OWQ4LTkwOTAtZTRlMmY4YzYzMGRhLTEwb253OjEyOTE0NjphbGwsNXE2LDV4cSw5bmo6MTQ3MDIwMTg6MjE6MTMzMTAzOTo3MzM6OjoxLjA2OjA6NjE0NTM2NzIxOjE6Mjk1NjI6MDo6OjI6MTIxLjIwMC41NC4yMDY6TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzYxLjAuMzE2My4xMDAgU2FmYXJpLzUzNy4zNjo6MC4wOjA6MDo4ODQtMToxNjoxOjA6MDo0Ojo6MTUwOTYyMDkyODc2MjpmYWxzZQ&fpc=99e43293-2827-4598-9d0d-c435bc993f90-10o79&i=U932w528X919&s=https%253A%252F%252Ftimesofindia.indiatimes.com%252Fcity%252Fchennai%252Fsaffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism%252Farticleshow%252F61453672.cms&u=http%3A%2F%2Fwww.zeeayurveda.com"><img src="https://static.clmbtech.com/ctn/29562/images/1/4d5ffb68e4894fba91c1c7d591c0e194_1492689364595_0.jpg"><span>Improve your power, vigor, vitality & stamina</span><i class="sponsor">ZEEAYURVEDA</i></a></li><li><a href="https://ade.clmbtech.com/evnt/click.htm?r=MjExMTI4YjYtZGUwOS00OWQ4LTkwOTAtZTRlMmY4YzYzMGRhLTEwb253OjEyOTE0NjphbGwsNXE2LDV4cSw5bmo6MTcyNDAwMDY6MjoyMTMyNzkyOjczMzo6OjIuMzY3OTQ4MTAxODkxNzIxOjA6NjE0NTM2NzIxOjE6NDI2OTg6MDo6OjI6MTIxLjIwMC41NC4yMDY6TW96aWxsYS81LjAgKFdpbmRvd3MgTlQgMTAuMDsgV2luNjQ7IHg2NCkgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzYxLjAuMzE2My4xMDAgU2FmYXJpLzUzNy4zNjo6MC4wOjA6MDoyNTMxLTE6MTY6MTowOjA6NDo6OjE1MDk2MjA5Mjg3NjI6ZmFsc2U&fpc=99e43293-2827-4598-9d0d-c435bc993f90-10o79&i=U932w528X919&s=https%253A%252F%252Ftimesofindia.indiatimes.com%252Fcity%252Fchennai%252Fsaffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism%252Farticleshow%252F61453672.cms&u=http%3A%2F%2Fwww.custom-trackx.com%2Fa860c2d2-aed7-4e80-a5e4-3faf4641310f%3Fadid%3Ddx15%26head%3DBurn_upto_20_kgs_with_this_easy_method%26imag%3D20"><img src="https://static.clmbtech.com/ctn/42698/images/1/14273eeb71eb1757d2034faf2bebde5a_1508757357992_0.jpg"><span>Burn upto 20 kgs with this easy method.</span><i class="sponsor">Nutralyfe</i></a></li></ul><div class="alR"><span class="clmblogo">Recommended By Colombia<i class="clmcup"></i></span></div></div></div><br>
Kamal pointed out that Tamil Nadu's Dravidian tradition is thousands of years old and said the social revolution brought on by Ramanujam 1,000 years ago is a landmark.
<div class="last7brdiv"></div><br>
<div class="last6brdiv"></div><br>
Kamal wrote, "There is no possibility that the attempt by fascists to shift the world towards the right will succeed. The shift towards the right is only a temporary fashion, a cosmetic change. It will not last. The backward old generation, particularly those belonging to the upper castes, which is rattled by the equality evolving in society, is trying to feed their caste-driven, backward ideology to the young generation by sugar coating it and presenting it as a modern idea."
<div class="last5brdiv"></div><br>
<div class="last4brdiv" data-topcmt-status="true"><div class="show_wdgt topcomment" data-plugin="show-comments"><div class="msg"><h2><span>Top</span> Comment</h2><span class="cmnttxt">if Hindus would have adapted terrorism, then shameless chapa like him would not existed.</span><span class="cmntauthor">OMSM</span></div><input type="button" data-plugin="show-comments" data-type="allcomment" class="btn" value="See All Comments" pg="TopComment#SeeAllComments#https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms"><input type="button" data-plugin="show-comments" data-showtype="autofocus" data-type="addcomment" class="btn" value="Add Comment" pg="TopComment#AddComment#https://timesofindia.indiatimes.com/city/chennai/saffron-terrorism-kamal-haasan-says-right-wing-hindus-have-started-employing-terrorism/articleshow/61453672.cms"></div></div><br>
Stating that the affinity that human race has towards science and wisdom will draw them towards rationalism despite opposition, Kamal said, "The youth in the state are not waiting for the change to happen. They have stepped into the fray to protect Tamil Nadu."
<div class="last3brdiv"></div><br>
<div class="last2brdiv"></div><br>
According to him, the conservatives are not stressing on what needs to be learned from the past tradition. "Destroying agriculture for commercial gains and selling mythology as history are evils they have been tirelessly carrying forward for ages," he wrote.
<div class="last1brdiv"></div><br>
<br>
</div>
</div>
</div>
相關問題
- 1. 是否可以使用css3 scale縮放容器大小(不縮放內容)?
- 2. 縮放UITextView和內容大小
- 3. 可調Div容器的文字(放大和縮小)
- 4. 將div縮小爲內容大小
- 5. 我在哪裏可以找到一個可以通過滑塊放大和縮小div內容的插件?
- 6. 縮放CALayer內容的大小
- 7. 是否可以將內容插入DIV但DIV保持相同大小?
- 8. 是否可以在pyqt4中縮放QVBoxLayout的內容?
- 9. 是否可以收縮包裝內容?
- 10. 是否可以在iOS Safari中檢測放大/縮小事件?
- 11. 是否可以通過縮放更改Rich標記大小?
- 12. 是否可以擴大沒有內容的div的高度?
- 13. 無需調整大小重新縮放div內容
- 14. 如何縮小內容以適合div?
- 15. DIV移動時放大和縮小
- 16. 縮放窗口大小的div div
- 17. jQuery/CSS縮放div內容
- 18. 是否可以「縮小」PdfPtable?
- 19. 如何以編程方式放大/縮小WebView的內容?
- 20. 放大和縮小
- 21. 調整大小和縮放HTML5畫布和內容
- 22. 如果不調整<iframe>本身的大小,是否可以縮放<iframe>的內容?
- 23. 當調整大小/放大/縮小頁面時,Div可以左右移動
- 24. Redis - 數據大小是否可以大於內存大小?
- 25. 內容(大小)是否可以與父項匹配?
- 26. Div對齊以放大和縮小爲中心
- 27. 是否可以僅提取可滾動div的可見內容?
- 28. 光流可用於放大和縮小
- 29. 是否有可能獲得縮放大小的UIControl?
- 30. 編輯:如何放大和縮小javafx Hbox可拖動節點中的內容
CSS變焦將做到這一點。只要確保你縮放的div在另一個隱藏溢出的div內。打開這個頁面上的控制檯並輸入'$(「#question」)。css(「zoom」,2)' – Archer
是否有你不能使用canvas的原因?除了使用WebGL或SVG之外,這聽起來非常適合您的需求。 – knightsbore
嘗試http://janne.aukia.com/zoomooz/ –