I thought it would be very troublesome to use CSS in ASP. NET, but it was very easy to do. The usage process is briefly recorded as follows:
CSS can be used in two situations: static addition and dynamic conversion.
1. Static addition:
Add the following content to aspx (add the head tag ):
<Link rel = "stylesheet" href = "pagecss.css" type = "text/css">
Define the pagecss.css file:
P {font-size: 9pt}
A: hover {font-size: 9pt; color: # FF0000; text-decoration: none}
A: link {font-size: 9pt; color: # 0000FF; text-decoration: none}
A: visited {font-size: 9pt; color: #990099; text-decoration: none}
. Button {font-size: 9pt; background: lightgreen; border-color: black; border-width: 1pt; height: 20}
Use CSS to define the style of a button in the aspx file:
<Asp: Button id = "Btn_query" runat = "server" Text = "Search" CssClass = "button"> </asp: Button>
Ii. dynamic transformation:
In asp.net, sometimes CSS needs to be dynamically changed, for example, sometimes personalized pages can be implemented.
1 2 <link id = "MyStyleSheet" rel = "stylesheet" type = "text/css" runat = "server"/>
3 {
MyStyleSheet. Attributes. Add ("href", "/css/flostyle.css ")
}