search
HomeWeb Front-endHTML Tutorialhtml 布局;css3+jq 下拉菜单;table分页动态添加行;html5本地存储;简单易用的html框架_html/css_WEB-ITnose

简单好用的html框架,预览图见最后; 源码;

1.页面布局使用table;

  table 嵌套 +iframe 布局;

2.下拉菜单为jq+css3 动画;

  css input 无边框,select下拉菜单美化

1 input{appearance:none;background-color:transparent;border: solid 0px #000;} /*input 无边框*/2 input:disabled{background-color:#d2d2d2;border:0px;}3 select {border: solid 1px #000; appearance:none;-moz-appearance:none; -webkit-appearance:none; padding-right: 14px;margin :0px;background: url("../images/arrow.png") no-repeat scroll right center transparent;}4 select::-ms-expand { display: none; } 5 select:disabled{background-color:#d2d2d2;} /*禁用时背景色*/

 

添加菜单,可以在js目录下的、js/cm_menu.js中添加;

1 var menus=new Array();2 menus[0]=['菜单1', '',[['演示1','page/11_page.html'],['演示2','page/12_page.html']]];3 menus[1]=['菜单2', '',[['演示1','page/21_page.html'],['演示2','page/22_page.html']]];

菜单css3

 1 ul.menu, 2 ul.*{margin:0px;padding:0px;} 3 ul.menu ul {padding:0;margin:0;list-style:none;position:relative;background:#ddd;font-family:arial, sans-serif;} 4 ul.menu {z-index:100;padding:10px;border-radius:10px 10px 0 0;margin:0 auto;} 5 ul.menu ul { 6     z-index:50;border-radius:0 0 10px 10px; 7     -webkit-transition: 0.5s; 8     -moz-transition: 0.5s; 9     -ms-transition: 0.5s;10     -o-transition: 0.5s;11     transition: 0.5s;12 }13 ul.menu li {line-height:30px;position:relative;text-indent:10px;list-style-type:none;}14 ul.menu > li {margin-top:2px;font-size:12px;}15 ul.menu > li a {font:normal 12px/30px arial, sans-serif;color:#fff;text-decoration:none;}16 ul.menu label.open {display:block;background: #DEEEF1 url("/jscss/demoimg/201208/d-arrow.gif") no-repeat 170px 12px;line-height:30px;position:relative;z-index:100;font:normal 12px/30px arial, sans-serif;color:#000;font-weight:900;;border-radius:10px 10px 0 0;}17 ul.menu label.open b {color:#DEEEF1;}18 ul.menu span {display:block;background:#00c;line-height:30px;position:relative;z-index:100;border-radius:10px 10px 0 0;}19 ul.menu label img {position:absolute;left:0;top:0;width:100%;height:30px;}20 21 ul.menu ul li {margin-top:-30px;22     -webkit-transition: 0.5s;23     -moz-transition: 0.5s;24     -ms-transition: 0.5s;25     -o-transition: 0.5s;26     transition: 0.5s;27 }28 ul.menu ul li a {display:block;font:normal 11px/30px arial, sans-serif;color:#000;background:#ccc;}29 ul.menu ul li a:hover {background:#ddd;}30 ul.menu input {position:absolute;left:-9999px;}31 32 ul.menu li input:checked + label {background:#069;} 33 ul.menu li input:checked ~ ul {background:#ccc;padding-bottom:10px;}34 ul.menu li input:checked ~ ul li {margin-top:0;}  35 36 ul.menu label.close {display:block;height:30px;background:transparent url("/jscss/demoimg/201208/u-arrow.gif") no-repeat 170px 12px;line-height:30px;position:relative;left:0;z-index:90;margin-top:-30px} 37 ul.menu input.tabs:checked ~ label.close {display:block;z-index:200;}38 ul.menu input.close:checked + label.close {display:none;}39 ul.menu input.close:checked ~ ul {background:#ddd;padding-bottom:0;}40 ul.menu input.close:checked ~ ul li {margin-top:-30px;}

 

部分代码如下:

 1 ...... 2         <td height="100%" style="background-image:url(images/menu_bgT.gif); background-repeat:no-repeat" valign="top"> 3         <ul id=navmenu class="menu"> 4         </ul> 5         </td> 6 ...... 7 <script type="text/javascript"> 8     try { 9              for (i=0; i < menus.length; i++)10             {11                 $("#navmenu").append('<li id=level' + i + '>');12                 $('#level' + i ).append('<input type="radio" name="tab" id=tab' + i + 'a class="tabs">');13                 $('#level' + i ).append('<label for=tab' + i + 'a class="open" accesskey="2">' + menus[i][0] + '</label>'); /*添加第一级菜单*/14                 $('#level' + i ).append('<input type="radio" name="tab" id="tab' + i + 'ac" class="tabs close">');15                 $('#level' + i ).append('<label for=tab' + i + 'ac class="close" accesskey="3"></label>');16                 $('#level' + i ).append('<ul id=second' + i + '>');17                 var submenu=menus[i][2];18                 for (j=0; j < submenu.length; j++)19                 {/*添加二级菜单*/20                     $('#second' + i).append('<li><a href=' + submenu[j][1] + '?'+ Math.random() +' target=page>' + submenu[j][0] + '</a></li>');    21                 }22                 $('#level' + i ).append('</ul>');23                 $("#navmenu").append('</li>');24             }25     } 26     catch (e) 27     {/*新的js中部分属性不支持,提示异常*/28         alert(e.name  + e.message + "\n"  + "浏览器版本太低请尝试使用Firfox、谷歌浏览器、IE9+ 浏览器预览\n");29     }30 31     $('#tab0a').attr("checked", true);  /*第一个菜单选中*/32 </script>33 ......

3.table 分页显示 ,新增行,使用jq;

  1 var currentPage = 1; /*当前是第几页*/  2 var showTableTr  = 10; /*每页显示多少行*/  3   4 /*新增行*/  5 function addTr()  6 {  7     sum++;  8     /*显示隐藏的行*/  9     $('tr[name="hidetr"]:last').find("th").eq(0).text($("#tableList tr").length -2); 10     $('tr[name="hidetr"]:last').show(); 11      12     /*复制最后一行,添加到最后一行后面,然后隐藏*/ 13     $('tr[name="hidetr"]:last').after($('tr[name="hidetr"]:last').clone(true)); 14     $('tr[name="hidetr"]:last').hide(); 15      16     if("BGCgray" == $('tr[name="hidetr"]:last').attr('class')) 17     { 18             $('tr[name="hidetr"]:last').removeClass('BGCgray'); 19     } 20     else  21     { 22         $('tr[name="hidetr"]:last').addClass('BGCgray');     23     } 24      25     if(currentPage != parseInt(getSumPage())) 26     {     27         tabPaging(parseInt(getSumPage())); 28     } 29 } 30 /*删除行*/ 31 function delTr(node) {    32     var tr1 = node.parentNode.parentNode;   33     var index = tr1.rowIndex; 34         var tab = document.getElementById("tableList"); 35  36         tab.deleteRow(index); 37  38         /*序号重排*/ 39         for(i = index; i < tab.rows.length - 2; i++) 40         { 41             tab.rows[i].cells[0].innerHTML = i.toString();     42         } 43          44         tabPaging(currentPage); 45 }   46 /*分页*/ 47 function tabPaging(page) 48 {     49     currentPage = page; 50     for(i = 1; i < getTabTrLength("tableList") + 1; i++) 51     { 52         $("#tableList tr").eq(i).hide();     53     } 54      55     var end = (page*showTableTr) > getTabTrLength("tableList")? getTabTrLength("tableList") : page*showTableTr; 56     for(i = (page - 1)*showTableTr + 1; i < (end + 1); i++) 57     { 58         $("#tableList tr").eq(i).show();     59     } 60 } 61 function getTabTrLength(tname) 62 { 63         return $("#" + tname + " tr").length - 3; 64 } 65 /*上一页*/ 66 function prePage() 67 { 68     if(1 == currentPage) 69     { 70         currentPage =parseInt(getSumPage()); 71     } 72     else  73     { 74         --currentPage;     75     } 76     tabPaging(currentPage); 77 } 78 /*下一页*/ 79 function nextPage() 80 { 81     if(parseInt(getSumPage()) == currentPage) 82     { 83         currentPage = 1; 84     } 85     else  86     { 87         ++currentPage;     88     } 89     tabPaging(currentPage); 90 } 91  92 /*总共可以分几页*/ 93 function getSumPage() { 94     sumtr = getTabTrLength("tableList"); 95     return (sumtr/showTableTr + (sumtr%showTableTr == 0 ? 0 : 1));  96 } 97  98 function setKey(_key,val) 99 {100     localStorage.setItem(_key,val);101 }102 function getKey (_key) {103     return localStorage.getItem(_key);104 }105 106 /*  提交*/107 function submitChange()108 {109     /*保存当前页*/110     setKey("currentPage",currentPage);111 }112 113 /*初始化数据*/114 function htmlload()115 {116     if(window.localStorage)117     {118         var a = null;119         if(getKey("currentPage") == a)120         {121             currentPage = 1;    122         }123         else 124         {125             currentPage = getKey("currentPage");126         }127     }128     else 129     {130         alert('该浏览器不支持html5,请使用Google,Firfox等浏览器');131     }132     $('tr[name="hidetr"]:last').hide();    133     134     tabPaging(currentPage);135 }

 

预览图:

 

author:1003278902@qq.com<br />download: http://files.cnblogs.com/files/zl1990/html.tar.gz

 

Statement
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
What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

What is the purpose of the <iframe> tag? What are the security considerations when using it?What is the purpose of the <iframe> tag? What are the security considerations when using it?Mar 20, 2025 pm 06:05 PM

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

What is the viewport meta tag? Why is it important for responsive design?What is the viewport meta tag? Why is it important for responsive design?Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools