• I have a page that displays an excerpt, which links to it’s post. Here’s the code:

    <?php if ($pagename!=""){
    	query_posts(array('category_name'=>$pagename));
    	if(have_posts()) : while(have_posts()) : the_post(); 
    ?>
    	<h2><?php the_title();?></h2> 
    <?php  if (has_excerpt()){?>
    	<p><?php the_excerpt(); ?></p>
    a href="<?php echo get_permalink(); ?>" class="right-justified"> Read More...</a>
    <?php 				}
    					else{ ?>
    						<p><?php the_post();?>
    <?php
    					}
    				endwhile;
    				endif;	
    				wp_reset_query();
    			}
    ?>

    Here’s the css:

    
      background-image:url('old-paper.jpg');
      background-size:cover;
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-color:red;
      position:relative;
      width:100%;
      height: 80%;
      padding-top:10%;
      display: flex;
    

    The problem I’m having is that the background for the linked post stops at the same place it was at for the excerpt. That is, the “cover” function doesn’t adjust for the longer post length. Not only does the background image not scale to fill the div, but neither does the background color. How do I fix this?

    • This topic was modified 6 years, 6 months ago by dsguffey.
    • This topic was modified 6 years, 6 months ago by dsguffey.
    • This topic was modified 6 years, 6 months ago by dsguffey.
    • This topic was modified 6 years, 6 months ago by Steven Stern (sterndata). Reason: replaced blockquote with backticks
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Please provide a link to a page on your site where we can see this. Thanks.

    Thread Starter dsguffey

    (@dsguffey)

    It’s not live. My website only exists on localhost at the moment. I’d be happy to send screenshots or more code if that’s possible.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Try “contain” instead of cover. Without a link to a live site, it’s hard to say.

    Thread Starter dsguffey

    (@dsguffey)

    No luck. Is there any free wordpress web hosting that you’d recommend? I’ve tried for hours to try and figure this thing out, and I don’t think I’ll be able to do it without help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can’t get my background to scale with my post.’ is closed to new replies.