So I have this HTML code with the following CSS.
HTML
<div class="secondpostholder">
<div class="rightsecond">
<h1>
<a href="<?php the_permalink();?>" alt="<?php the_title();?>" title="<?php the_title();?>">
<?php the_title();?>
</a>
</h1>
<div class="firstmetaholder">
<p class="secondentrymeta">
by
<span class="secondauthormeta">
<?php the_author();?>
</span>
• <?php the_date(); ?>
</p>
<p class="secondentryexcerpt">
<?php
$content = get_the_content();
echo wp_trim_words( $content , '30' ); ?>
</p>
<div class="secondreadmoreholder">
<a class="secondreadmorea" href="<?php the_permalink();?>" alt="<?php the_title();?>" title="<?php the_title();?>">
Read More
</a>
</div>
</div>
</div>
<?php $background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'TypeOne' ); ?>
<div class="leftsecond" style="background-image: url('<?php echo $background[0]; ?>');">
<a class="leftseconda" href="<?php the_permalink();?>" alt="<?php the_title();?>" title="<?php the_title();?>">
</a>
</div>
</div>
CSS
secondentry {
display:inline-block;
width:100%;
}
.secondentryholder {
width:100%;
max-width:1120px;
margin:0 auto;
position:relative;
height:100%;
}
.secondpostholder {
margin-bottom:60px;
}
.rightsecond{
width: 420px;
right:0;
position: absolute;
margin-left:30px;
}
.secondpostholder {
clear:both;
}
.leftsecond{
background: #222;
float:left;
width:calc(100% - 450px);
min-height:400px;
background-repeat:no-repeat;
display:block;
position:relative;
background-position:center center;
}
You may visit the website that I'm working on to have a clear picture of what's going on.
Once you opened the website, resize your browser window to 600px and check out the second post ("We found love in a hopeless place") to the sixth post ("The Undisputed Truth: What Happens If You Don’t Pay Your Credit Card Bills? ") and see what happens.
My problem is, Is there a way where in the "leftsecond" DIV would be on the top of the "rightsecond"?
I know this can easily be done by modifying the HTML structure BUT please be informed that the original CSS Style of the two divs are floating.
What I'm trying to achieve here is related to media queries, when the screen is large, the two divs are floated to each other. There's no problem with the code of this. The problem lies when the screen is small and I want to remove the FLOATS then the "leftsecond div" would be at the TOP and the "rightsecond div" at the BOTTOM.
The two div
s don't have the same height. Only the "leftsecond" div
has a fixed height. The rightsecond div
has a fluid height which changes according to it's content.