Search code examples
phprss

Display RSS with PHP Correctly


I have a sample RSS from Amazon. While the RSS displays correctly with images aligned to the left, but when I try displaying the same RSS, the images do not align to the left, but to the top and this is not what I want. I need it to display exactly the same way as the one on top

I have included the images here, my display is the second on the bottom - I'd like it displayed like the one on top. Here's the PHP code I've been using and the RSS file.

Any help will be gratefully appreciated.


Solution

  • You must define css stylesheet to format the display elements, without a stylesheet you are falling back on user / user-agent stylesheets.

    for simplicity, I would reformat the html code to something meaningful:

    <a class="link">#</a>
    <div class="itemWrap">
      <img src="snooze.jpg" alt="" />
      <p class="description">lorem ipsum dolor...</p>
    </div>
    

    this way you can nicely float the image to the left (the div.itemWrap serves as a boundary for the floated image)

    .itemWrap img{
      float: left;
      margin-right: 10px;
    }
    
    .itemWrap{
      display: block;
      margin-bottom: 40px;
    }
    

    hope it helps