Image and Div side by side

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    Image and Div side by side

    Hello,

    I have a container div and inside it I have an image and another div
    which I want to place side by side:

    <div id="container" >
    <img id="image"/>
    <div id="content">
    </div>

    Is it possible to float the image left and the div right and make them
    side by side with CSS?

    I know how to do this by placing the image inside another div but I
    would like to avoid that.

    Thanks,
    Miguel

  • Jukka K. Korpela

    #2
    Re: Image and Div side by side

    Scripsit shapper:
    <div id="container" >
    <img id="image"/>
    <div id="content">
    </div>
    You should have posted a URL and not a fragment of HTML, which isn't even
    what you've really got (you hardly have that badly invalid markup).
    Is it possible to float the image left and the div right and make them
    side by side with CSS?
    Yes. What's the problem with that? You need to set the width for the div, of
    course. And if they are just floated that way, they might appear rather far
    from each other, but that's really what you asking for.

    Or maybe you actually want them to appear _near_ to each other, on the left.
    Then float both of them left (and set some reasonable margin between them).
    I know how to do this by placing the image inside another div but I
    would like to avoid that.
    Why would you avoid that, and what have you really done? Telling the URL
    might reveal what the desired appearance really is.

    --
    Jukka K. Korpela ("Yucca")


    Comment

    • Gus Richter

      #3
      Re: Image and Div side by side

      shapper wrote:
      Hello,
      >
      I have a container div and inside it I have an image and another div
      which I want to place side by side:
      >
      <div id="container" >
      <img id="image"/>
      <div id="content">
      </div>
      >
      Is it possible to float the image left and the div right and make them
      side by side with CSS?
      Yes, but depending on what you want to do and on dimension requirements,
      you may not need to float the div at all since the div will
      automatically flow to the right of the image.
      I know how to do this by placing the image inside another div but I
      would like to avoid that.
      I don't understand why you would want to do that. You can float the
      image directly without placing it into a div.

      --
      Gus

      Comment

      Working...