title: Moving Elements in DOM for Responsive Web Design
body: <h2>A Brief Explanation</h2>
  
  <p>I have created a responsive website that effectively has three views (desktop,tablet,mobile). Most of the design is changed via CSS using media queries (as it should be for responsive websites). However, part of the design is too complex to simply be manipulated via CSS as the HTML actually needs to be moved around the DOM. I know this doesn't sound too great but I cannot see how else I am meant to replicate this design without moving certain elements within my HTML.</p>
  
  <p>So, with the above in mind, I now plan to write a function that creates custom events for each of the different ‘responsive views’. When each event is fired (in sync with the CSS media queries), it will execute some Javascript to move/animate any elements that cannot be manipulated enough using CSS.</p>
  
  <h2>My Question</h2>
  
  <p>Is this the best method to go about doing this? If, not, what other options do I have? Are there any existing libraries that I could look at and learn from?</p>
  
  <p><strong><em>My actual question is; What is the best method of moving elements in the DOM for responsive web design?</em></strong></p>
  
  <h2>Further Explanation</h2>
  
  <p>If the above wasn’t clear, then read the following:</p>
  
  <p>Consider these three different views:</p>
  
  <p><img src="https://i.stack.imgur.com/ODxC8.png" alt="Responsive Views"></p>
  
  <p>Now consider the code for the first two views:</p>
  
  <p><strong>Desktop</strong></p>
  
  <pre><code>&lt;div id="some_container"&gt;
      &lt;nav&gt;
          &lt;ul&gt;
          &lt;/ul&gt;
      &lt;nav&gt;
      &lt;p&gt;Some Text&lt;/p&gt;
      &lt;!-- The rest of the content --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Tablet</strong></p>
  
  <pre><code>&lt;div id="some_container"&gt;
      &lt;p&gt;Some Text&lt;/p&gt;
      &lt;nav&gt;
          &lt;ul&gt;
          &lt;/ul&gt;
      &lt;nav&gt;
      &lt;!-- The rest of the content --&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong><em>Notice the <code>nav</code> tag has been moved below the <code>p</code> tag...</em></strong></p>