1

I have the following structure:

<div class="container">
<div class="outside">
<img src="http://cox-applicators.com/images/brochures/vertical-ad-07-
singles.jpg" class="imgs">
</div>
</div>

CSS:

 .outside {
      position:absolute;
 }
 .imgs {
      float: right;
      margin-right: 30px;
 }
 .container {
     width: 960px;
 }

I have to use absolute because of another div that contains content.

Question: How can I make the image float right with using margin-left while still having absolute on the containing div?

Here's the fiddle:

http://jsfiddle.net/erjQH/

2 Answers 2

3

just add this line of css to ur code.

.outside {
      position:absolute;
      right:0; /* Add this to ur Code */
  }

With this u dont need to apply float to image and it will be aligned left

or

u can do this add this line to ur code and your image will be aligned right without float.

.imgs{          
          position:relative;
          right:0px;
       }
1

you can achieve this by adding right:30px; in your .outside class without the need of .imgs class

Fiddle - http://jsfiddle.net/U2WUK/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.