Results 1 to 12 of 12

Thread: Define CSS (Newbie)

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Define CSS (Newbie)

    Apologies, I think a newbie question here, searched, but can't seem to find.

    What's the best way to define a css file for your .aspx pages? Can't find a property for the page or document.

    Strange enough, when you start a new C# ASP.NET application, you don't even get a default Styles.css. So I created a new VB ASP.NET app and copied that Styles.css to my C# project. Now I need to "link" to the .css so all my pages will use the same styles.

    Thanks,
    Mike

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Define CSS (Newbie)

    In the <head> section, add

    <link rel="stylesheet" href="stylesheetname.css">

    The lazy man's way would be, open the HTML view of your aspx page, and drag that css file into the page. It'll create the tag for you.

  3. #3

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Define CSS (Newbie)

    Thanks, mendhak, for the reply. I guess I know how to use that with HTML pages, is there any more to it with ASP.NET? In particular, if I put a Web Forms Label on the designer, it has a property named "CssClass". I set this to H1 or whatever, and nothing looks different during design or runtime. Or am I doing this wrong?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Define CSS (Newbie)

    Have you set any special formatting for H1 in your CSS?

  5. #5

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Define CSS (Newbie)

    Err, umm, no To be honest, I really don't know what I'm doing. I just grabbed the Styles.css created by a new VB.NET ASP.NET project - I will try, though. Thanks.

  6. #6

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Define CSS (Newbie)

    Again, I'm a newbie at this. I have an aspx page, added this to the <head>:
    <link rel="stylesheet" href="Styles.css">

    In the designer, I added a Web Forms Label and the HTML looks like:
    Code:
    			<asp:Label id="lblMendhak" style="Z-INDEX: 110; LEFT: 528px; POSITION: absolute; TOP: 48px"
    				runat="server" Height="32px" Width="160px" CssClass="H1">mendhak</asp:Label>
    You can see that in the properties page, I made the CssClass set to H1. My Styles.css has this:
    Code:
    H1, H2, H3, H4, H5, TH, THEAD, TFOOT
    {
        COLOR: #0D5692;
    }
    The default color was #003366, but I changed, just to see if anything would change. Styles.css is in the virtual directory.

  7. #7
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345

    Re: Define CSS (Newbie)

    That CSS is defining the style for the H1 element, not a class called H1. If you wanted a H1 class, you could use this:
    Code:
    .H1
    {
        COLOR: #0D5692;
    }

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Define CSS (Newbie)

    Give your CSS classes better names so as to avoid confusions like this one.

    Here's a CSS tutorial btw, you can quickly run through it. CSS is extremely easy. Once you get the basic idea, it's just a matter of applying it and referencing google once in a while.

    www.w3schools.com/css

  9. #9
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345

    Re: Define CSS (Newbie)

    Yeah, as an extension on what Mendhak said, I always try to name my classes depending on what they're going to be used for. Such as
    Code:
    .code
    {
         font-family: "Courier New",Courier, Arial;
         font-size: 10pt;
    }
    Again, just to eradicate any confusion.


  10. #10
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464

    Re: Define CSS (Newbie)

    You can take your stylesheet in the solution explorer and drag it onto the aspx page on the design surface. This stops you from having to paste the html on every page, you can just drag a stylesheet over.

  11. #11

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Resolved Re: Define CSS (Newbie) [Resolved]

    ok - makes sense now. Thanks all for the info.

  12. #12
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: Define CSS (Newbie) [Resolved]

    Quote Originally Posted by Mike Hildner
    ok - makes sense now. Thanks all for the info.
    You can also use style tags inline... in the <head> section of a webpage, if you wish to customize that page seperately from an externally referenced stylesheet.

    Code:
    <head>
    <style type="text/css">
    .h1 { font-family: verdana,arial,helvetica,sans-serif; color: #CC6600; font-size: medium; }
    .h1color { font-family: verdana,arial,helvetica,sans-serif; color: #CC6600; font-size: small; }</style>
    </head>

Posting Permissions

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



Click Here to Expand Forum to Full Width