Repeater_Table_单击_Repeater样式,Table样式,交替变色,单击变色
最近做项目[xiang mu]用到Repeater,没有好的样式只能套一个Table来设置[she zhi]交替行颜色、鼠标[shu biao]经过颜色、单击[dan ji]颜色,网上艘了一下资料整理了一下,具体的效果如下,
前台[qian tai]的Html代码[dai ma]如下:
代码[dai ma]
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <% @ Page Title = "" Language = " c# " MasterPageFile = " ~/SystemBase/MainMasterPage.master " AutoEventWireup = " true " CodeFile = " Spreater.aspx.cs " Inherits = " Spreater " %> < asp:Content ID = " Content1 " ContentPlaceHolderID = " ContentPlaceHolder1 " runat = " Server " > < script src = " App_Js/JSCommon.js " type = " text/javascript " > </ script > < div style = " width: 800px " > < ContentTemplate > < asp:Repeater ID = " Rep " runat = " server " > < HeaderTemplate > < table id = " Tab " class = " Rep_tab " > < tr > < th style = " width: 120px " > 组编号 </ th > < th style = " width: 120px " > 组名称 </ th > < th style = " width: 100px " > 组上级编号 </ th > < th style = " width: 120px " > 序号 </ th > < th style = " width: 80px " > 层次 </ th > < th style = " width: 160px " > 子组数据[shu ju] </ th > < th style = " width: 160px " > 标志 </ th > </ tr > </ HeaderTemplate > < ItemTemplate > < tr > < td ><% #DataBinder.Eval(Container.DataItem, " GroupID " ) %></ td > < td ><% #DataBinder.Eval(Container.DataItem, " G_CName " ) %></ td > < td ><% #DataBinder.Eval(Container.DataItem, " G_ParentID " ) %></ td > < td ><% #DataBinder.Eval(Container.DataItem, " G_ShowOrder " ) %></ td > < td ><% #DataBinder.Eval(Container.DataItem, " G_Level " ) %></ td > < td ><% #DataBinder.Eval(Container.DataItem, " G_ChildCount " ) %></ td > < td > <% #DataBinder.Eval(Container.DataItem, " G_Delete " ) %></ td > </ tr > </ ItemTemplate > < FooterTemplate > </ table > </ FooterTemplate > </ asp:Repeater > </ div > </ div > </ ContentTemplate > </ div > < script type = " text/javascript " language = " javascript " > window.onload = SetTableColor( " Tab " ); </ script > </ asp:Content >
JavaScript代码[dai ma]如下:
代码[dai ma]
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> function SetTableColor(TableID) { var clickClass = "" ; // 点击样式名 var moveClass = "" ; // 鼠标[shu biao]经过样式名 var clickTR = null ; // 点击的行 var moveTR = null ; // 鼠标[shu biao]经过行 var Ptr = document.getElementById(TableID).getElementsByTagName( " tr " ); for (i = 1 ; i < Ptr.length + 1 ; i ++ ) { Ptr[i - 1 ].className = (i % 2 > 0 ) ? " Rep_Tab_EvenTr " : " Rep_Tab_OddTr " ; } // 设置[she zhi]鼠标[shu biao]的动作事件[shi jian] for ( var i = 1 ; i < Ptr.length; i ++ ) { var Owner = Ptr[i].item; // 鼠标[shu biao]经过事件[shi jian] Ptr[i].onmouseover = function Move() { if (clickTR != this ) { if (moveTR != this ) { moveClass = this .className; moveTR = this ; this .className = " Rep_Tr_Move " ; } } } // 鼠标[shu biao]离开事件[shi jian] Ptr[i].onmouseout = function Out() { if (clickTR != this ) { moveTR = null ; this .className = moveClass; } } // 鼠标[shu biao]单击[dan ji]事件[shi jian] Ptr[i].onclick = function Ck() { if (clickTR != this ) { if (clickTR) { clickTR.className = clickClass; } clickTR = this ; clickClass = moveClass; } this .className = " Rep_Tr_Click " ; } } }
CSS样式代码[dai ma]如下:
代码[dai ma]
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> /* -----------------Repeater 控件内部Table样式定义----------------- */ /* Repeater内部Table的样式 */ .Rep_tab { width : 100% ; margin : 0px auto ; font : Georgia 11px ; font-size : 12px ; font-family : Tahoma, Arial, Helvetica, Sans-serif, "宋体[song ti]" ; color : #333333 ; text-align : center ; vertical-align : middle ; border-collapse : collapse ; /* 细线表[xian biao]格代码[dai ma] */ } /* Repeater内部Table的td样式 */ .Rep_tab td { border : 1px solid #4d9ab0 ; /* 细线表[xian biao]格线条颜色 */ height : 25px ; } /* Repeater内部Table的caption样式 */ .Rep_tab caption { text-align : center ; font-size : 12px ; font-weight : bold ; margin : 0 auto ; } /* Repeater内部Table的TR的奇数行样式 */ .Rep_Tab_OddTr { background-color : #f8fbfc ; color : #000000 ; height : 25px ; } /* Repeater内部Table的TR的偶数行样式 */ .Rep_Tab_EvenTr { background-color : #e5f1f4 ; color : #000000 ; height : 25px ; } .Rep_Tab_HeaderTr { background-color : #ffffee ; color : #000000 ; } /* 鼠标[shu biao]经过的颜色 */ .Rep_Tr_Move { background-color : #ecfbd4 ; color : #000000 ; height : 25px ; } /* 鼠标[shu biao]点击的颜色 */ .Rep_Tr_Click { background-color : #bce774 ; color : #333333 ; height : 25px ; }
注意:
在界面[jie mian]内添加JS和CSS的引用[yin yong],记得是在你的Table的后面,添加如下代码[dai ma]:
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> < script type = " text/javascript " language = " javascript " > window.onload = SetTableColor( " Tab " ); < / script>
Repeater_Table_单击_Repeater样式,Table样式,交替变色,单击变色相关推荐
- Bootstrap 之Table样式
将<table>标签添加class='table' 类后的样式 <html> <head><meta name="viewport" co ...
- 还不错的Table样式和form表单样式
作为一个后台开发人员而言,拥有一套属于自己的前台样式是比较重要的,这里分享一下自己感觉还不错的样式,以后遇到好的,还会陆续添加 上图: 带鼠标滑动效果的table样式看起来比较清爽 样式 <he ...
- [转载] html转word table样式_[Python02] Python-docx包的使用,快速处理 Word 文件!
参考链接: 通过Python-Docx模块在Python中读写MS Word文件 日常需要经常处理Word文档,发现了一个新的Python包:Python-docx,处理docx十分方便. 而且这个包 ...
- Html漂亮的table样式模板
模板案例: table样式: <style scoped> table{border-collapse: collapse;margin: 0 auto;text-align: cente ...
- 手机端自适应表格table样式如何写
有时候我们的网页需要展示一些表格的内容,在pc端是很好控制它的展现方式的,但是到移动端就非常难控制了,那么该怎么做呢? 比如上图就是没控制好的移动端的表格table样式,展示非常的凌乱. 这个就是写好 ...
- 去除bootstrap的table样式中单元格边框线
使用bootstrap的table样式,在非纯白背景下,会有单元格边框线,影响美观. 去除方式: <style type="text/css"> bod ...
- html表格展开格式,4款简单常见的纯CSS表格(table)样式
本文介绍4款简单常见的纯CSS表格(table)样式. 1.默认表格(default table) 添加pure-table类样式化表格, 此类向表元素添加填充(padding)和边框(borders ...
- css 设置 table 样式:表头固定,内容垂直方向滚动
css 设置 table 样式:表头固定,内容垂直方向滚动 一.需求 二.实现 一.需求 需要实现下面样式的表格,其中,表头固定.内容垂直方向滚动.鼠标悬停高亮.点击高亮. 基本样式可参考 w3sch ...
- html table专业样式,html 简单的table样式
1 2 3 4 5 html 简单的table样式 6 7 /*gridtable*/ 8 table.gridtable{ 9 font-family:verdana,arial,sans-seri ...
- ant design vue table表格组件实现隔行变色
ant design vue table表格组件实现隔行变色 一.使用方法 html代码: <a-table:columns="patient":data-source=&q ...
最新文章
- 面试常备题---链表总结篇
- 如何实时查看mysql当前连接数
- 【机器视觉】 halcon中图像获取
- 导数,微分,偏导,全微分,方向导数,梯度
- php游客随机代码,php生成随机码的一段代码
- id和instancetype的区别
- linux weblogic 内存溢出,weblogic 安装升级补丁出现内存溢出问题解决
- 对象流 ObjectOutputStream java
- Bootstrap3 源代码样式
- 用python画生日蛋糕-祝你生日快乐
- 点歌APP开发解决方案详解
- ปอเช็ตติโน่ เสียดายโอกาสของทีมในเกมฟัดหงส์
- ROS项目开发实战(三)——使用QT进行ROS的GUI界面设计(详细教程附代码!!!)
- php 必须实现方法,php – 错误:类必须声明为抽象或实现其余的方法
- 模型预测控制(MPC)+逻辑控制(相平面分区控制)--matlab例程介绍
- SATA硬盘与IDE硬盘的优劣势对比
- 22/02/17学习笔记
- 计算机英语教程第六版pdf,计算机英语教程.pdf
- 服务器系统日志事件id41,系统不定时重启,事件ID41,任务类别63
- python集合怎么表示_Python 集合(Set)、字典(Dictionary)