css写法
html或 jsp引入外部css样式:
<link href=”${contextPath}/htuser/css/global.css” rel=”stylesheet” type=”text/css” />
css写法
注:如果在.css文件中,直接写样式
如果在jsp中写样式,需要在写在<style type=”text/css”></style>中
1.直接给html标签定义样式
ul { list-style:none;margin:0;padding:0;}
table {table-layout: fixed;}
多个标签同时定义
ul,li {
margin: 0;
padding: 0
}
dl,dt,dd,h1,h2,h3,h4,h5,h6,p,form { margin:0;padding:0;}
2.根据id定义样式
#container {
overflow: auto
}
多个id同时定义样式
#pager2,#pager3,#pager4{
background: #eff5ff;
color:black;
}
3.根据class定义样式
.inpuGrey{
background-color: lightgray;
}
多个class同时定义
.btn_left, .btn_right{
clear: both;
color:#fff;
line-height:32px;
height: 32px;
position:relative;
margin:0px;
width:100%;padding-left:15px;
padding-right:15px;
margin:0px;
background: url(../images/ydzy_img/search_bg_left.png) no-repeat left top;
}
4.指定id下指定class的子元素的样式:(可以反过来用,通过class找id)
#sidebar .content1 {
height:auto;
position:absolute;
top:30px;bottom:7px;width:116px;
background:url(../images/ydzy_img/left_tree_center.png) repeat-y center top;
}
5.给所有的文本框定义样式
input[type=”text”]{
width:40%;
}
下拉
select{
width:50%;
}
给所有的文本框和下拉框定义样式
input[type=”text”],select{
width:40%;
}
给按钮定义样式
input[type=button]{width:63px;height:23px;text-align:center;line-height:23px;color:#fff;font-size:12px;border:0px;background:transparent url(../images/btn_bgs.png) repeat-x center center;}
给id=”citySel”的文本框定义样式
input[type=”text”]#citySel{
width:60%;
}
给id=”grid”的表格的行列定义样式
#grid tr{border-right:1px solid transparent}
#grid td{font-size:13px;}
给class=”pg_pager”下的所有td定义样式
.pg_pager td{border:0px;color:rgb(34, 34, 34);font-size:14px;}
6.根据路径定义内层样式,例如找到内层表格的td并定义样式(可以越级,但是路径要正确)
.main_bodys_wyyfsgl #searchCondition>div> table td{
width:200px;
}
.main_bodys_vyywh #searchCondition>div> table td>span
{
position:absolute;
left:85px;right:0px;
width:auto;
}
.main_bodys_vyywh #searchCondition>div> table td>span input[type=text],table td>span select {margin-top:0px !important;width:100%}
.main_bodys_wyyfsgl .ui-dialog .ui-dialog-content form{padding-right:50px}
.main_bodys_vyywh img#show{float:left;}
.main_bodys_vyywh img#showE{float:left;}
注:如果是找下级 id或class之间用空格,如果并列定义同一个样式用逗号 *****html自有标签和id或class之间可以不用空格 img#showE
实际过程中要根据情况调试
滚动条一般用在div标签
style=”overflow-y:scroll;”
#addform,#editform{
overflow: auto;
}
7.同时使用两种样式 例如 class=”btn-block button-ripple”
版权声明:本文为zl-programmer原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。