How to control the image resolution painted as the background for a div

I am trying to paint an image as the background for a div element. But not able to figure out on how to control the resolution of the image.

My image resolution is 1400X900 px. I wanted to paint that image so that it wont be trimmed and fits to the screen. How to set the image size so that it will be fitted to screen? I tried using background-size but it is not working in I.E.

below is my div element

<div style="background:url('...');">
    some more elements
</div>

Answers


background-size (background-size: contain for instance) is the way to go. However, as you yourself note, this doesn't work in IE 8 and below.

For old IEs you can consider using background-size polyfill, which emulates background-size.

You could write a script that does the same thing but that might be more trouble than it's worth.


Use Css3 option background-size.

For example background-size:100% 100%;


Need Your Help

How do I scroll to the cursor position in an NSTextView?

macos scroll nstextview

How can I make programmatically an NSTextView scroll to the cursor position?

C Socket Programming: reopen and reconnect socket

c multithreading sockets

I am testing out my code for reconnection in case the connection drop. However I'm facing some Segmentation Error after the socket is re-opened and re-connected.