Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    48
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Stretch div background to fit inside its parent div

    Solved, sorry can't delete. Thanks for reading in anycase.
    Hi, I'm trying to get a div with a background to stretch to its parent div size.
    I'm having trouble though as the child won't define its size to the parent. Was wondering if anyone had any insight.
    Code:
    <div id="parent">
        <div id="child"></div>
    </div>
    
    
    #parent {
                 width:200px;
                 height:200px;
    }
    
    #child {
                max-height:100%;
    	    max-width:100%;
                background:url('images/1.png');
                background-size: 100%;   
                margin:auto;
                display:block;
               position:relative;
    }
    *edit* nm it's not max-height/max-width, just width/height.
    Last edited by 7Blake; 12-10-2013 at 04:11 PM. Reason: edit solived


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •