1

How can I insert two images in css, center them ?

I would like to have something like that: link

My actual css look like this, with one image centered :

position: absolute; 
top: 0; 
bottom:0; 
left: 0; 
right:0;
margin: auto;
4dgaurav
  • 11,360
  • 4
  • 32
  • 59
  • 1
    What do you mean with making 2 images centered at the same time? I do not see how that works out in your link either. Also where is your HTML? What selector does that CSS use? Could you post a [jsfiddle](http://jsfiddle.net)? – MarioDS Jun 08 '14 at 10:17
  • Thank you MdeSchaepmeester and mostafaznv ,for the my next question i will post a jsdiffle. I have figured it out with the post from oopsoft. Anyway i appreciate your support. :) – SoSkandalouS Jun 08 '14 at 15:53
  • Thanks i have figured it out :). http://jsfiddle.net/SoSoDef/FYHTQ/ – SoSkandalouS Jun 08 '14 at 16:06

3 Answers3

0

u can use margin-top or right and set position:absolute for img element in css

Live DEMO

CSS:

img{
    position:absolute;
    margin-top:100px;
    right:25%;
    width:50%;
}
#leftdiv{
    position:relative;
    float:left;
    background: #e7e7e7;
    height:500px;
    width:50%;

}
#rightdiv{
    position:relative;
    float:right;
    height:500px;
    width:50%;
    background: green;

}

HTML:

<div id='leftdiv'>
    <img src='http://icdn4.digitaltrends.com/image/microsoft_xp_bliss_desktop_image-650x0.jpg'/>
</div>
<div id='rightdiv'>
     <img src='http://icdn4.digitaltrends.com/image/microsoft_xp_bliss_desktop_image-650x0.jpg'/>
</div>
mostafaznv
  • 958
  • 14
  • 24
0

modifying the answer of this example : link

check that demo

css

.image_container {
    width: 50%;
    height: 300px;
    line-height: 300px;
    background: #eee;
    text-align: center;
    float:left;
}

.image_container img {
    vertical-align: middle;
}

Html

<div class="image_container">
     <image src="http://placehold.it/100x100/" height="100" width="100" alt=""/>
</div>
<div class="image_container">
     <image src="http://placehold.it/100x100/" height="100" width="100" alt=""/>
</div>

,also you can check that page

Community
  • 1
  • 1
ooopsoft
  • 410
  • 2
  • 6
-2

Set width for image container.

Set margin : 0 auto;