• I’ve been doing searching and can’t really find anything (maybe I don’t know the correct search terms to explain my issue).

    Currently, I’m working on getting my semi-transparent header to match up over my background image: http://www.mark-pimentel.com

    They are both 1000px wide but only match up when the browser window is resized to the width of 1000px

    I’d like to get the header and background image (actually, it’d be ideal for all the elements I will later include in the page) to stay in the center of the page regardless if the window is resized or not.

    i.e. If I were to make the window smaller, the divs don’t move and continue to keep the same “scale” or spacing apart from each other regardless of browser window size.

    Any help would be greatly appreciated guys!

    here’s my css:

    body {
    	font-family: arial;
            background: #ffffff url('http://www.mark-pimentel.com/wp-content/themes/scratch/images/main2.jpg') fixed no-repeat top center;
            height:1300px;
            width:1000px;
    }
    
    .clear {
    	clear:both;
    }
    
    #header {
            background: url(http://www.mark-pimentel.com/wp-content/themes/M45TH2/i/header-bg.png) fixed no-repeat top center;
    	height: 263px;
    	overflow: hidden;
    }
    
    #header-wrapper {
                    width: 1000px;
                    height:263px;
    
    }
    
    #content-wrapper {
    	width: 250px;
            height:900px;
    
    }
    
    #content {
            background-color:rgba(0,0,0,0.5);
    	width: 250px;
            margin: 20px auto 20px;
            padding: 10px 0 0 10px;
    }
Viewing 1 replies (of 1 total)
  • To center divs using css you need to set a width, and do a margin: 0 auto.
    Doing that will keep the div aways centered if window width is greater than div’s width…

    Instead of defining background into body, it’s better to define it inside a div… that div will contain the other div with the logo.. both using width:1000px, and margin:0 auto….

    If the idea is to keep body bg fixed regardless of scrolling, just do a position fixed on the div…

    Hope i’ve understood your problem right, and that this will solve your problem! =)

Viewing 1 replies (of 1 total)
  • The topic ‘Locking Header to Background Image – Clean window resizing CSS Help’ is closed to new replies.