1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Center an image

Discussion in 'CSS' started by GotOwned, Nov 30, 2009.

  1. #1
    I'm trying to make a header, left image, middle image and right image. But I can't find the way

    .topbandl { background-image: url(images/l_header.png);  float: left; font-size: 10px; height:105px; position: relative; width: 20px;}
    .topbandm { background-image: url(images/header_bg.png);  margin:auto; font-size: 10px; height:105px; position: relative; width: 879px; }
    .topbandr { background-image: url(images/r_header.png);  float: left; font-size: 10px; height:105px; position: relative; width: 19px; }
    Code (markup):

    In the php

    <div class="topbandl">
      <div class="topbandm">
    <div class="topbandr"></div>
    Code (markup):
    THANKS
     
    GotOwned, Nov 30, 2009 IP
  2. taminder

    taminder Peon

    Messages:
    581
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    #topband { display: table; }
    .topbandl { background-image: url(images/l_header.png);  font-size: 10px; height:105px; position: relative; width: 20px; display: table-cell; }
    .topbandm { background-image: url(images/header_bg.png);  margin:auto; font-size: 10px; height:105px; position: relative; width: 879px; display: table-cell; }
    .topbandr { background-image: url(images/r_header.png);  font-size: 10px; height:105px; position: relative; width: 19px; display: table-cell; }
    Code (markup):
    <div id="topband">
      <div class="topbandl"></div>
      <div class="topbandm"></div>
      <div class="topbandr"></div>
    </div>
    Code (markup):
    you may also need to add vertical-align: top; if you want to line them up (on each)
     
    taminder, Dec 1, 2009 IP
    GotOwned likes this.
  3. FilmFiddler

    FilmFiddler Greenhorn

    Messages:
    54
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    23
    #3
    Perhaps something like this:

    .topband { 	
    		margin: auto; 
                    width: 918px; 
    }
    .topbandl, .topbandm, .topbandr { 	
    		float: left; 
    		position: relative;
        		font-size: 10px; 
    }
    .topbandl { 	
    		background: url(images/l_header.png) no-repeat;
        		height:105px; width: 20px; 
    }
    .topbandm { 
    		background: url(images/header_bg.png) no-repeat;
        		height:105px; width: 879px; 
    }
    .topbandr { 
    		background: url(images/r_header.png) no-repeat;
        		height:105px; width: 19px; 
    }
    Code (markup):
    <div class="topband">
      <div class="topbandl"></div>
      <div class="topbandm"></div>
      <div class="topbandr"></div>
    </div>
    Code (markup):
     
    FilmFiddler, Dec 1, 2009 IP
  4. GotOwned

    GotOwned Well-Known Member

    Messages:
    409
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Thanks, code worked, rep added.
    Is there any way to make the width of topbandm automatic, example if the monitor is 700 px then covers 700 px, if is 300 PX covers 300 px, etc.

    Also one more thing, an image in front of the topbandl (Logo)(With link)

    THANKS A LOT!
    Best Regards
     
    GotOwned, Dec 2, 2009 IP
  5. thr3146

    thr3146 Active Member

    Messages:
    182
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Have you tried using percentages, instead of fixed width?
     
    thr3146, Dec 2, 2009 IP
  6. GotOwned

    GotOwned Well-Known Member

    Messages:
    409
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #6
    Well atm that isn't important, I tried using the same code for the footer


    PHP
    <div id="footerdesign">
      <div class="footerdesignl"></div>
      <div class="footerdesignm"></div>
      <div class="footerdesignr"></div>
    		<?=$lang['Footer'];?></div>
    Code (markup):
    CSS
    #footerdesign { display: table; }
    .footerdesignl { background-image: url(images/l_footer.png);  font-size: 10px; height:105px; position: relative; width: 20px; display: table-cell; }
    .footerdesignm { background-image: url(images/footer_bg.png);  margin:auto; font-size: 10px; height:105px; position: relative; width: 999px; display: table-cell; }
    .footerdesignr { background-image: url(images/r_footer.png);  font-size: 10px; height:105px; position: relative; width: 19px; display: table-cell; }
    Code (markup):

    But the text (lang['Footer']) appears at the right instead of infront of the background footer.

    Thanks a lot
     
    GotOwned, Dec 2, 2009 IP
  7. mikestrand

    mikestrand Active Member

    Messages:
    237
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #7
    Just a note on this to GotOwned, Filmfidlers code is actually better than previosuly suggested, particularly cross-browser. Not sure how high IE 6/7/8 is on your agenda but FilmFidler's code will be much more stable cross-browser.

    Can you let me know what that php footer tag is actually outputting? it may need an addition element wrapper to be aligned the way you want it.
     
    mikestrand, Dec 3, 2009 IP
  8. taminder

    taminder Peon

    Messages:
    581
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    you would have to use % instead of fixed pixel width. to make it 700px from the start, you would have to measure the pixels in your browser first.

    if you want it to be maximum 700 pixels, place it inside a div code where the maximum width is 700px.


    edit: thanks for the +rep also.
    and if you need anymore help, please let me know via PM. I just so happened to check back at this thread because I received the +rep
     
    taminder, Dec 3, 2009 IP