two easy questions

Discussion in 'ASP.NET 2.0' started by collegefootballsim.com, Jan 17, 2008.

  1. Hey guys,

    I have two easy questions. I've just not come across the answers yet.

    1. How do I center my website on the explorer page?

    2. How do I change the image/color of the background sitting behind my website?

    Thanks!
     
  2. You sometimes need to use multiple methods unless you can force your visitors to use a certain browser.

    An old school method is with table layouts.
    But nowadays CSS should be used as it's compliant with newer standards and renders faster.

    If you're using Visual Studio 2008 it has very good CSS support.
    You should learn how to work with a style sheet then apply styles to sections of your site.

    Centering and background colors can all be done with CSS styles.

    If you are working in VS 2008 I suggest you watch this:
    http://asp.net/learn/3.5-videos/video-230.aspx

    If you need specific code help let me know.
     
  3. mjp

    mjp

    I used to center with CSS because I drank the CSS KoolAid and wanted to do all layout control through CSS. The problem with that is, as you hinted, browser compatibility. The hoops you have to jump through to make much of CSS "universal" are ridiculous and cumbersome. Most of that fault falls on our friends at Microsoft. 95% of the CSS "hacks" I have had to use were to accommodate nonstandard behavior in IE.

    So you know how I center content now? Tables. ;) Since the advent of CSS tables have been relegated to the moldy basement of design, but I have been using them more often lately, because they just work. Everywhere.




    mjp
    ---
    DiscountASP.NET
     
  4. Yup. [​IMG]

    We could bounce this around for ages, just talking about standards in its own matrix.

    I have to admit some of the things Visual Studio warns about now seems rather odd.
    As an example, it doesn't like me to use xHTML in break tags even if I close them, but...
    Even VS 2008 is missing the ID and runat settings by default, unless you use an addin that is.

    This is a tough one right now in the ASP.NET community.
    Use CSS to center an ASP.NET panel and IE will center it but Firefox will move it to the left...
    Unless you use the tried and true methods VS is still listing as legacy warnings.

    I've had fun with GridView controls blowing out on Firefox too.
    The only way I've been able to constrain the template rows is with tables.

    Man I really fell the need to take a few aspirins now. [​IMG]
     
  5. Ok

    So, my website is basically a standard 3 x 3 table. How do I center it? I have tried and tried to center align my website trying to click on the main 3 x 3 table but have had no luck.

    Also, I've been delving into css, but i still have figured out the 'command' if you will for changing the color of page outside of my content (basically all the empty space my site does not take up)

    btw, you guys are awesome. fast with answers that are always helpful
     
  6. mjp

    mjp

    You don't mention what you're using to build your site, but in very basic write-it-in-notepadHTML terms:


    <table align="center">


    will center that table on the page.
    Background via CSS would be:

    body {
    background: #FFFFFF;
    }

    Replacing "FFFFFF" with the hex value for whatever background color you're looking for. Otherwise the background is set inside the tag.





    mjp
    ---
    DiscountASP.NET
     
  7. just for the record visual web developer 05

    thanks, i'll try those out

    ok, tried those out

    if i put

    body{background:black
    }

    in my css file and then apply it to my document then it turns my webpage black. i want to change the color of the space outside my webpage.

    and i have a <table style> in my masterpage where i have the height and width defined. I can't figure out which command will let me center the table. obvious choices like, oh i dont know, 'align' aren't there.

    sorry for being an idiot

    Post Edited (collegefootballsim.com) : 1/18/2008 2:58:09 AM GMT
     
  8. mjp

    mjp

    You may have to define a background color for your table(s) so they don't inherit the body background color.

    Does that <table style> get its input from a CSS file?You might have guessed thatI'm not all that familiar with master pages. But the CSS for table background is just like the body background (assuming you want it to apply to all tables):
    table {
    background: #FFFFFF;
    }

    The "background" property, by the way, can contain all the different background properties. To specifically do background color only you would use

    table {
    background-color: #FFFFFF;
    }

    mjp
    ---
    DiscountASP.NET

    Post Edited (mjp [DASP]) : 1/18/2008 11:25:29 PM GMT
     
  9. To get my main CSS working from the master page and the background image this worked best for IE7 and Firefox2:

     

Share This Page