How to Use CSS in ASP. NET?

Source: Internet
Author: User

The specific method can be:

1. Use theme, right-click the website name, select the Asp.net folder, and select app_themes to add a topic without a Chinese name, such as theme1.
2. Right-click themes, create an item, and select CSS,
3. Merge the code into: (you do not need to write the style header and tail)
. FU1 {
Font-size: 12px;
Color: red;
Font-family: "_ gb2312"
}
. FU2 {
Font-size: 12px;
Line-Height: 20px;
Color: # 0033cc;
}
A. OK: link {
Font-size: 12px;
Color: #993300;
Text-Decoration: none;
}
A. OK: hover {
Font-size: 12px;
Color: # ff99cc;
Text-Decoration: none;
}
A. OK: Active {
Font-size: 12px;
Color: # 6699cc;
Text-Decoration: none;
}
A. OK: visited {
Font-size: 12px;
Color: # cc3333;
Text-Decoration: none;
}
A: link {
Font-size: 12px;
Color: # 0066cc;
Text-Decoration: none;
}
A: hover {
Font-size: 12px;
Color: #009900;
Text-Decoration: none;
}
A: active {
Font-size: 12px;
Color: # 0066cc;
Text-Decoration: none;
}
A: visited {
Font-size: 12px;
Color: # 0033cc;
Text-Decoration: none;
}
Table {
Color: # ff9900;
Background-color: # cccccc;
}
4. Add the following to the first line of code in the source view of the page to be used:
Theme = theme1
5. The most useful controls
<Asp: Label id = "label1" runat = "server" text = "username:" cssclass = "FU1"> </ASP: Label>

You can also find a CSS file on the Internet.

Directly copy to project

For example, maing.css

Then you can add this sentence to the page where you want to use this style.
<Link href = "main.css" rel = "stylesheet" type = "text/CSS">

Manage styles (CSS)
1. Three Ways to embed a style sheet:
// Declare a uniform style in the header
<Style type = "text/CSS"> body {font-size: 9pt ;}</style>

// Embed an identical table file from the external
<LINK rel = "stylesheet" type = "text/CSS" href = "mystylesheet.css">

// Defined directly in element attributes
<P style = "font-size: 9pt"> </P>

2. assign a style rule to an element.
<Style type = "text/CSS">
<! -- Tagname {styleproperty1: value1; styleproperty2: value2;...} -->
</Style>

3. Customize a style for a class of Elements
. Mystyle {font-size: 9pt ;}
<P class = "mystyle"> </P>

4. Customize a style for a single element
# Myid {font-size: 9pt ;}
<P id = "myid"> </P>

5. Dynamic Modification of the page style sheet link after page loading
<Link id = "basicstyle" rel = "stylesheet" type = "text/CSS" href = "styles.normal.css">
Document. getelementbyid ("basicstyle"). href = "newstyle.css ";

6. open/close a style sheet
Document. stylesheets [1]. Disabled = false;

7. dynamically set/change the style of an element
Document. getelementbyid ("myelement"). classname = "mystyle ";

8. element style priority
// In principle, the browser uses the last style (proximity principle)
// When the ID and class styles are set for an element at the same time, the ID style takes precedence over the class
// When both Class and style are set for an element, style takes precedence over class.
// When you set both style and ID for an element, style takes precedence over ID.
<Style>
. Mystyle {font-size: 10pt ;}
# Myid {font-size: 11pt ;}
</Style>
<P id = "myid" class = "mystyle" style = "font-size: 12pt"> 123 </P>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.