The use of CSS styles in ASP.NET

零下一度
Release: 2017-04-27 13:55:44
Original
2111 people have browsed it

1 Use the link tag to call the style, that is, call the style in the css file. You can directly drag the CSS file to the head of the html page

This method loads the css first, and then loads the html

<head runat="server">
   <title>网页标题</title>
   <link href="Css/default.css" rel="stylesheet" type="text/css" />   
</head>
Copy after login

2 Use style tag

<head runat="server">
   <title>网页标题</title>

   <link href="Css/default.css" rel="stylesheet" type="text/css" />
  
   <style type="text/css">
        body
        {
            width:100%;
        }
        
   </style>

</head>
Copy after login

3 import loading, load html first, then load css

   <style type="text/css">
        
        @import url(&#39;css/default.css&#39;);
        
   </style>
Copy after login

4 Use in default.css

1 If you only write the type of control, it means that controls of this type use this style

2 If you want to modify a certain control To set the style, use

# For example: defaullt.css file

body 
{
    padding: 0px;
    margin: 0px;
    width:960px;
    height:auto;
    display:block;
    margin-left:auto;
    margin-right:auto;   
}
        
#p_Top
{
  width:100%;
  height:80px;
  margin:0 auto;
  background-color:White;
  display:block;
}

#p_Mid
{
  width:100%;
  height:auto;
  margin:0 auto;
  background-color:White;
  display:block;
  min-height:420px;
}

#p_Footer
{
    width:100%;
    height:30px;
}


#Select,#Insert,#Delete,#Update
{
   width:90px;
   margin-left:auto;
   margin-right:auto;
   height:90px;
   font-size:15px;
   border: 3px solid #33CCFF;
}

#Select:hover,#Insert:hover,#Delete:hover,#Update:hover
{
     cursor:pointer;
     background-color:#33CCFF;
}
Copy after login

5 For controls, you can use attributes to load styles

1 Use the style attribute to directly use style=" width:auto; height:auto; margin-left:auto; margin-right:auto;"

2 Use class to call head The style in

3 Use CssClass to call the style in head

<style type="text/css">
    
     .Bt
      {
           width:80px;
           height:25px;
           border:none;
      }
       
       .Bt:hover
       {
           cursor:pointer;
           background-color:#33CCFF;
       }
       
       .closed
       {
            border-style: none;
            height:21px;
            width:21px;
            background-image: url(&#39;/Images/closed.png&#39;);
            background-repeat:no-repeat;
       }
       
       .closed:hover
       {
           cursor:pointer;
       }
    
    </style>
Copy after login

6 Add the style to the front button in the background

bt.Attributes.CssStyle.Value = "background-color:Gray;";
Copy after login

7 You can use iterative writing

to set the style of li under ul under Menu

#Menu ul li
		{
			width:100%;
			
			border:1px dotted gray;
			margin:0;
			padding:0;
		}
Copy after login

The above is the detailed content of The use of CSS styles in ASP.NET. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template