Currently, I have been developing a template for a database-driven page that is supposed to contain four divs for content arranged like this:
----- -----
| 1 | | 2 |
----- -----
----- -----
| 3 | | 4 |
----- -----
The information in each box will always remain the same. For example, news will always be in box #1 and images in box #2. Depending on the available content, there could be all four sections displayed or only one. In cases where a box is missing, such as box 2, I am looking for a way to make box 1 expand to fill the width of the parent div.
For instance:
-----------
| 1 |
-----------
----- -----
| 3 | | 4 |
----- -----
or if boxes 3 & 4 do not exist:
-----------
| 1 |
-----------
-----------
| 2 |
-----------
It seems like achieving this might require conditional statements, but I am curious if there is a CSS or jQuery solution. It should be a simple task, but I am struggling to figure it out.
I tried setting up two floating divs with 50% width side by side, but I am unsure how to handle expansion when one of them is missing.
Thank you!
Edit: Including HTML! Nothing too complex here...
<div class="auth-secondary">
<div class="auth-upcoming auth-3d">
<span class="auth-h3">Upcoming Events</span>
<p>
<strong>March 5, 2014</strong><br>
Book signing
</p>
<p>
<strong>March 5, 2014</strong><br>
Ice cream party
</p>
</div><!-- end auth-upcoming -->
<div class="auth-media auth-3d">
<span class="auth-h3">Media Gallery</span>
<p>
<img src="http://placehold.it/74x74">
<img src="http://placehold.it/74x74">
<img src="http://placehold.it/74x74">
<img src="http://placehold.it/74x74">
</p>
</div>
</div> <!-- end auth-secondary-->