SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

Centre Image on Screen Dynamically

Last post 07-24-2008, 19:59 by Orikuuido. 7 replies.
Sort Posts: Previous Next
  •  07-23-2008, 17:57 13622

    Centre Image on Screen Dynamically

    I've just received an image for the top banner of a site I'm busy on, and the guy who made it put lots of empty colour on both sides of the main image, so that regardless of screen width, we can always have the main image in the centre, equidistant from the sides.  How can I mark up this image to achieve this, if I even can?  Right now, as a plain image, it's fully left aligned and is broadening its TD to the right, off the screen.  I <s>need </s> want to dynamically always have the centre of the image at the centre of my screen, with both sides cropped
    Unscrambling Eggs: Decompiling ASP.NET
  •  07-23-2008, 18:10 13624 in reply to 13622

    Re: Centre Image on Screen Dynamically

    I'm not sure what you mean. Do you want to align it in the center of the page, both vertically and horizontally? I'm thinking if it's a banner just wrap it in a div and in the css just say

    #myPrettyBannerThingy {

    clear: center; /* don't know if it is middle or center. didn't test. */

    }


    I'm going to regret forging this...
  •  07-24-2008, 6:06 13630 in reply to 13622

    Re: Centre Image on Screen Dynamically

    Try using <center></center>
  •  07-24-2008, 9:53 13634 in reply to 13630

    Re: Centre Image on Screen Dynamically

    Hi riaans,

    never use <center></center>. Those tags are legacy, as far as I am concerned. I am sure that like the name attribute in the form tag, <center></center> will be deprecated in HTML 5.0 Surprise


    I'm going to regret forging this...
  •  07-24-2008, 11:09 13640 in reply to 13624

    Re: Centre Image on Screen Dynamically

    I used this:

    background-image: url(imageurl);
    background-repeat: no-repeat;
    background-position: center top;

     

     


    Unscrambling Eggs: Decompiling ASP.NET
  •  07-24-2008, 17:23 13661 in reply to 13640

    Re: Centre Image on Screen Dynamically

    Now I understand what you were trying to do. Surprise

    I thought you wanted an image in the foreground, but no, I was wrong


    I'm going to regret forging this...
  •  07-24-2008, 17:58 13662 in reply to 13661

    Re: Centre Image on Screen Dynamically

    There is nothing in the foreground, it's an empty TD, so the background serves quite well.

    Unscrambling Eggs: Decompiling ASP.NET
  •  07-24-2008, 19:59 13663 in reply to 13662

    Re: Centre Image on Screen Dynamically

    I feel like such a n00bcake now. If you remember my post on stretching a background-image, you'll notice that I basically had the code for you. Anyway, was validating my website now and it failed the xhtml 1.0 strict validation Crying
    I'm going to regret forging this...
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems