How to make background image with aspect ratio in html and css [closed]


Tags: jquery,html,css

Problem :

I have read many question on stackoverflow but couldn't find better answer for adding image with auto height and width :

here is example what i am trying to do :

visit : http://www.teleclub.ch

In this website when we resize window image auto positioned left and right not exactly resize.

So can any one tell me how i can do this ?



Solution :

background-size:cover + background-position:center actually will do the trick:

JsFiddle (drag the borders around to see)


    CSS Howto..

    How can I add image to facebook login button?

    How to stretch a background-image with css

    How to use an image more than one place in CSS

    How do I adjust position of a text inside a Bootstrap panel with overriden max-height?

    How to add physics to CSS animations?

    How to divide 3 divs(CSS + MVC)

    How to limit input text length using CSS3? [duplicate]

    How can i improve my javascript? codepen included

    How do you deal with Internet Explorer?

    Heroku Not Showing SCSS Background Images

    How to change font of select list items in the drop down

    How to vertically align a DIV next to an image?

    How do I display image flush with other images after a clear?

    How to force two elements become hovered at the same time?

    How to apply css to html so that it shows as the style property

    how to align the content to center of page using css

    How to make a table with no cells-per-row defined only with CSS

    jQuery How to select the only child of a
  • inside a class
  • how to remove css property using javascript?

    how to keep the aspect ratio of an image in bounding box - CSS

    How do I style a specific select option in HTML

    How to connect CSS files to my JSP pages stored in Web-Content (Dynamic Web Project)

    How to debug CSS when using GWT

    How to create responsive text on top of an image?

    CSS Specificity - how to overlap twitter-bootstrap

    how to change css of the image link when clicked?

    How to build flexible structure?

    cannot figure out how to make text appear inside div after hover animation

    How to align Facebook, Twitter, Google+ and LinkedIn buttons on the right?

    How detect first div clicked when all of them absolute