Search code examples
expressionenginechannel

Expression engine channel entries keep next to each other


I am trying to keep my channel entries next to each other.

Usual way to print channel entries:

{exp:channel:entries channel="news" limit="10"}
                <h2>{title}</h2>

               {news_body}
{/exp:channel:entries}

So the news print under each other like this:

  Title 1 Blah Blah

  ashdjsdsd asdsda ada
  adasdasda asdsda adad

  Title 2 Blah Blah

  jsaudwi llasdju alsl
  asdasdas

I want to print two news articles next to each other like this:

  Title 1 Blah Blah            Title 2 Blah Blah

  jsaudwi llasdju alsl        ashdjsdsd asdsda ada
  asdasdas                    adasdasda asdsda adad

Solution

  • imjared's answer is good from an HTML/CSS perspective, but since this is tagged as an ExpressionEngine question, here's how to solve this via EE syntax, with self-explanatory HTML.

    {exp:channel:entries channel="news" limit="10"}
    <div class="{switch="float-left|float-right"}">
        <h2>{title}</h2>
        {news_body}
    </div>
    {/exp:channel:entries}