Support » Fixing WordPress » Background image width and height

  • Resolved cableghost


    I’m trying to set a background image to a fill a div. Since the div surrounding the background image cannot be dynamic, I’m trying to fit the image within the div, whether it be to stretch it, or reduce it.

    Below is the functioning code I have to present the image. Every time I try resizing it via css, or style, it either does not appear, or it is tiled.

    $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000), false, '');
    <div class="gad-box">
    <div style="background: url(<?php echo $src[0]; ?> ) !important; height:100%; width:100%;">

    CSS for main div:
    .gad-box{ float:left; height: 280px; width: 336px; margin: 0 7px 0 0; }

    Thanks for the help.

Viewing 1 replies (of 1 total)
  • cableghost


    Determined there is no way to ‘crop’ background images during load.

Viewing 1 replies (of 1 total)
  • The topic ‘Background image width and height’ is closed to new replies.