htmlcss

How to position two elements side by side using CSS


I want to position a paragraph to the right of an <iframe> of a Google map.

I do not know how to show my code, so here is a screenshot of what I want:


Solution

  • Just use the float style. Put your google map iframe in a div class, and the paragraph in another div class, then apply the following CSS styles to those div classes(don't forget to clear the blocks after float effect, to not make the blocks trouble below them):

    css

    .google_map{
        width:55%;
        margin-right:2%;
        float: left;
    }
    .google_map iframe{
       width:100%;
    }
    .paragraph {
        width:42%;
        float: left;
    }
    .clearfix{
        clear:both
    }
    

    html

    <div class="google_map">
          <iframe></iframe>
    </div>
    <div class="paragraph">
          <p></p>
    </div>
    <div class="clearfix"></div>