Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to center images while keeping them responsive?
    primarykey
    data
    text
    <p>Hi please take a look at my site, below is the code snippet in question i have to center my images since ive never had any luck with the css-html methods. The problem is because its set to wait for document.ready() sometimes it will place all my images to the right. Ive tried window.load() but the images center offscreen at smaller window sizes. It was also suggested i try</p> <pre><code>&lt;div style=" background: url('Assets/image.png') center center no-repeat; width: 100%; height: 500px; "&gt; &lt;/div&gt; </code></pre> <p>but this causes it to lose responsiveness. Ive searched around and i cant find a solution, i just need my images (and the one form) to stay centered and for the images to scale down with the window size. </p> <p>site: <a href="http://bit.ly/11nAQJK" rel="nofollow">http://bit.ly/11nAQJK</a></p> <pre><code>&lt;script type="text/javascript"&gt; //Centering Script $(document).ready(function () { updateContainer(); $(window).resize(function() { updateContainer(); }); }); function updateContainer() { (function ($) { $.fn.vAlign = function() { return this.each(function(i){ var h = $(this).height(); var oh = $(this).outerHeight(); var mt = (h + (oh - h)) / 2; $(this).css("margin-top", "-" + mt + "px"); $(this).css("top", "50%"); $(this).css("position", "absolute"); }); }; })(jQuery); (function ($) { $.fn.hAlign = function() { return this.each(function(i){ var w = $(this).width(); var ow = $(this).outerWidth(); var ml = (w + (ow - w)) / 2; $(this).css("margin-left", "-" + ml + "px"); $(this).css("left", "50%"); $(this).css("position", "absolute"); }); }; })(jQuery); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload