|
-
Dec 3rd, 2004, 06:54 PM
#1
Thread Starter
Frenzied Member
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
-
Dec 4th, 2004, 12:12 AM
#2
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.
-
Dec 4th, 2004, 03:59 AM
#3
Thread Starter
Frenzied Member
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?
-
Dec 4th, 2004, 05:50 AM
#4
Re: Define CSS (Newbie)
Have you set any special formatting for H1 in your CSS?
-
Dec 4th, 2004, 05:55 AM
#5
Thread Starter
Frenzied Member
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.
-
Dec 4th, 2004, 06:14 AM
#6
Thread Starter
Frenzied Member
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.
-
Dec 4th, 2004, 04:57 PM
#7
Frenzied Member
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;
}
-
Dec 5th, 2004, 07:04 AM
#8
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
-
Dec 5th, 2004, 09:29 AM
#9
Frenzied Member
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.
-
Dec 5th, 2004, 01:03 PM
#10
PowerPoster
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.
-
Dec 6th, 2004, 11:04 AM
#11
Thread Starter
Frenzied Member
Re: Define CSS (Newbie) [Resolved]
ok - makes sense now. Thanks all for the info.
-
Dec 8th, 2004, 02:07 PM
#12
I wonder how many charact
Re: Define CSS (Newbie) [Resolved]
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|