Centering large image in small div with overflow visible

I want to centre a banner image of size 1920x225px in a div 960px wide. the problem occuring is that the image is not in the centre as it starts from top left. Heres an image to describing the issue http://tinypic.com/r/scco0m/5

Upvotes: 1

Views: 118

Answers (2)

VanGoghsCoffee
VanGoghsCoffee

Reputation: 58

Try using

background-position: center center;

on your background image.

https://developer.mozilla.org/en-US/docs/Web/CSS/background-position

Upvotes: 1

Dinesh Kanivu
Dinesh Kanivu

Reputation: 2587

You did not mention here, how you adding he image in a website

if you are giving background image

give css like this background:url(../image.jpg) center center no-repeat;

If you don't want background image just give max-width:100% for that image


New Answer.

You need to give position:relative for the div having width:960px

and for the image add like this

img{position:absolute; left:50px; top:20px; z-index:999}

You can change the Left and top value according to your Wish

Upvotes: 0

Related Questions