ASP.NET中使用CSS样式
2015-09-19 15:33
603 查看
1 使用link标签去调用样式,即调用css文件中的样式,可以直接将CSS文件拖拽到html页的head下面
此方法先加载css,后加载html
<head runat="server"> <title>网页标题</title> <link href="Css/default.css" rel="stylesheet" type="text/css" /> </head>
2 使用style标签
<head runat="server"> <title>网页标题</title> <link href="Css/default.css" rel="stylesheet" type="text/css" /> <style type="text/css"> body { width:100%; } </style> </head>
3 import加载,先加载html,后加载css
<style type="text/css"> @import url('css/default.css'); </style>
4 在default.css中的使用
1 如果只写控件的类型,表示该类型的控件都用这样的样式2 如果想对某一控件进行设置样式使用 #
举个栗子: defaullt.css 文件
body { padding: 0px; margin: 0px; width:960px; height:auto; display:block; margin-left:auto; margin-right:auto; } #Div_Top { width:100%; height:80px; margin:0 auto; background-color:White; display:block; } #Div_Mid { width:100%; height:auto; margin:0 auto; background-color:White; display:block; min-height:420px; } #Div_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; }
5 对于控件而言 可以使用属性加载样式
1 使用style属性 直接使用 style=" width:auto; height:auto; margin-left:auto; margin-right:auto;"2 使用class 调用head里的样式
3 使用CssClass 调用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('/Images/closed.png'); background-repeat:no-repeat; } .closed:hover { cursor:pointer; } </style>
6 后台为前台按钮添加样式
bt.Attributes.CssStyle.Value = "background-color:Gray;";
7 可以用 迭代写法
表示设置 Menu下的ul下的li的 样式#Menu ul li { width:100%; border:1px dotted gray; margin:0; padding:0; }
相关文章推荐
- asp.net,cookie,写cookie,取cookie
- 树莓派--Raspbian安装与设置
- 登陆时验证码的制作(asp.net)
- ASP.NET MVC请求特殊静态文件返回404 Not Found
- ASP.NET三层架构的分析
- 技术人生:故事之十七 ASP害得我好惨!
- asp.net mvc ajaxForm提交上传代办
- ASP.NET(C#)将数据导出到Word或Excel
- 技术人生:故事之十三 CGI,ASP?
- asp.net后台导出excel的方法一:使用response导出excel
- raspberry pi2 智能小车源码及测试视频
- raspberry pi2 智能小车源码及测试视频
- 利用metasploit攻击有ms8067漏洞的PC机过程
- 编译raspberry pi2内核
- C/S ASP.NET页面传值汇总
- ASP.NET加JS方式
- ASP.NET的checkboxlist,RadioButtonList,FileUpload,image控件的综合使用
- ASP调用WebService转化成JSON数据,附json.min.asp
- asp.net 连接字符串的多种写法
- ASP.NET中实现JSON和对象及集合之间互转,附JsonHelper辅助操作类