javascript - Align background image middle and center -


यहां एचटीएमएल है:

 <कोड> & lt; div class = "gallerybox" & gt; & Lt; a href = "/ CustomContentRetrieve.aspx? आईडी = 398791" & gt; & Lt; img alt = "" src = "/ उपयोगिताएँ / image.jpg" चौड़ाई = "400" ऊंचाई = "400" / & gt; & Lt; / a & gt; & Lt; / div & gt;  

यहां सीएसएस है:

  .gallerybox {width: 200px; ऊँचाई: 200px; अतिप्रवाह: छिपा हुआ;}  
< P> क्या कोई मुझे बता सकता है कि लिंक छवि को div.gallerybox मध्य (खड़ी) और केंद्र (क्षैतिज) के अंदर संरेखित करें? हो सकता है कि जावास्क्रिप्ट, jQuery या पूरी तरह से सीएसएस का उपयोग कर

हो सकता है कि निम्नलिखित की तरह कुछ:

< पूर्व> & lt; div class = "gallerybox" & gt; & Lt; a href = "/ CustomContentRetrieve.aspx? आईडी = 398791" & gt; & Lt; img id = "imgUtility" class = "Galleryimage" alt = "" src = "/ उपयोगिताओं / ShowThumbnail.aspx USM = 1 & amp;? श्याम = 400 & amp; amp; एच = 400 & amp; amp; आर = 1 & amp; amp ; img = {tag_image_value} "/ & gt;" / & gt; & lt; / a & gt; & lt; / div & gt; .gallerybox {width: 200px; ऊँचाई: 200px; अतिप्रवाह: छिपा हुआ;} & lt; - संपादित करें फिर - & gt! ; & lt; स्क्रिप्ट भाषा = "javaScript" & gt; window.onload = fixImage; समारोह fixImage () {var img = document.getElementById ( 'imgUtility'); var x = img.offsetWidth; वर y = img.offsetHeight; img। Style.left = - (x / 2); img.style.top = - (y / 2);} & lt; / स्क्रिप्ट & gt;

Comments

Popular posts from this blog

.net - C# List<T>.Find(x=>x.Rectangle.Contains(Point)) FAIL -

iphone - Smoothing a rounded stroke in Core Graphics -

c++ - QtQuick: QQmlApplicationEngine failed to load component qrc:/main.qml:23 Invalid attached object assignment -