主要运用了 CSS3 的 :checked 选择器,
代码结构跟使用js差不多,只是多了几个radio,
不知道性能上是js快还是css快呢?
codepen地址:http://codepen.io/YuanWing/pen/RPqvad
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> <title>CSS3 TAB</title> <style> body { font-family: 'Microsoft YaHei'; font-size: 14px; background-color: #f5f4f7; margin: 0; color: #252525; } a { text-decoration: none; } h3, h4 { margin: 0; font-weight: 400; font-size: inherit; } ul { padding-left: 0; list-style: none; margin: 0; } p { margin-top: 0; margin-bottom: 0; } .Jhds { position: relative; } .Jhds .radio { opacity: 0; position: absolute; } .Jhds .radio:nth-of-type(1):checked ~ .tab-title label:nth-of-type(1) { color: #fff; background-color: #498fee; } .Jhds .radio:nth-of-type(2):checked ~ .tab-title label:nth-of-type(2) { color: #fff; background-color: #498fee; } .Jhds .radio:nth-of-type(3):checked ~ .tab-title label:nth-of-type(3) { color: #fff; background-color: #498fee; } .Jhds .radio:nth-of-type(1):checked ~ .tab-outer .tab-inner:nth-of-type(1) { display: block; } .Jhds .radio:nth-of-type(2):checked ~ .tab-outer .tab-inner:nth-of-type(2) { display: block; } .Jhds .radio:nth-of-type(3):checked ~ .tab-outer .tab-inner:nth-of-type(3) { display: block; } .Jhds .tab-title { font-size: 0; padding: 15px; text-align: center; } .Jhds .tab-title label{ display: inline-block; color: #498fee; text-align: center; background-color: #fff; border: 1px solid #498fee; font-size: 14px; width: 30%; padding: 5px 0; } .Jhds .tab-title label:first-child { border-right: 0 none; border-top-left-radius: 5px; border-bottom-left-radius: 5px; } .Jhds .tab-title label:last-child { border-left: 0 none; border-top-right-radius: 5px; border-bottom-right-radius: 5px; } .Jhds .tab-outer .tab-inner { display: none; } .Jhds .tab-inner li{ position: relative; background-color: #fff; } .Jhds .title:after, .Jhds .tab-inner li:before, .Jhds .tab-inner li:last-child:after{ position: absolute; left: 0; content: ''; width: 100%; height: 1px; font-size: 0; background-color: #d9d9d9; -webkit-transform: scaleY(0.5); transform: scaleY(0.5); } .Jhds .tab-inner li:before { top: 0; } .Jhds .title:after, .Jhds .tab-inner li:last-child:after { bottom: 0; } .Jhds .title { padding: 10px; position: relative; overflow: hidden; } .Jhds .title .Jhds-num { color: #498fee; white-space: nowrap; } .Jhds .title .time { float: right; display: inline-block; } .Jhds .list { padding: 10px 60px 10px 10px; position: relative; color: #252525; display: block; } .Jhds .price { color: #f90; margin-top: 5px; } .Jhds .num { position: absolute; right: 30px; top: 50%; height: 20px; line-height: 20px; margin-top: -10px; } .arrow { position: absolute; right: 10px; top: 50%; margin-top: -6px; width: 10px; height: 10px; border-left: 1px solid #cfcfcf; border-top: 1px solid #cfcfcf; -webkit-transform: rotate(135deg); transform: rotate(135deg); } @media screen and (max-width:370px) { .Jhds .title .time { float: none; } } </style></head><body> <div class="Jhds"> <input checked class="radio" type="radio" name="Jhds" id="Jhds1"> <input class="radio" type="radio" name="Jhds" id="Jhds2"> <input class="radio" type="radio" name="Jhds" id="Jhds3"> <div class="tab-title"> <label for="Jhds1">待付款</label> <label for="Jhds2">待签收</label> <label for="Jhds3">已完成</label> </div> <div class="tab-outer"> <ul class="tab-inner"> <li> <h3 id="span-class-Jhds-num-进货单号-jkdjh-span-span-class-time-今天-进货-span"> <span class="Jhds-num">进货单号:jkdjh2015072623125699</span> <span class="time">今天 23:12 进货</span> </h3> <a class="list" href="###"> <h4 id="deg-飞天茅台最好的茅台浓香-ml">60°飞天茅台最好的茅台浓香1000ml</h4> <p class="price">待确认:¥129.00</p> <span class="num">X6</span> <span class="arrow"></span> </a> </li> </ul> <ul class="tab-inner"> <li> <h3 id="span-class-Jhds-num-进货单号-jkdjh-span-span-class-time-今天-进货-span"> <span class="Jhds-num">进货单号:jkdjh2015072623965199</span> <span class="time">今天 23:12 进货</span> </h3> <a class="list" href="###"> <h4 id="deg-西凤-middot-御宴酒-精装版-ml">50°西凤·御宴酒(精装版)500ml</h4> <p class="price">已发货:¥39.00</p> <span class="num">X1</span> <span class="arrow"></span> </a> </li> </ul> <ul class="tab-inner"> <li> <h3 id="span-class-Jhds-num-进货单号-jkdjh-span-span-class-time-今天-进货-span"> <span class="Jhds-num">进货单号:jkdjh2015072623126899</span> <span class="time">今天 23:12 进货</span> </h3> <a class="list" href="###"> <h4 id="法国富乐男爵干红葡萄酒豪华大礼包">法国富乐男爵干红葡萄酒豪华大礼包</h4> <p class="price">已签收:¥369.00</p> <span class="num">X6</span> <span class="arrow"></span> </a> </li> </ul> </div> </div></body></html>

HTML、CSS和JavaScript在网页开发中的角色分别是:HTML负责内容结构,CSS负责样式,JavaScript负责动态行为。1.HTML通过标签定义网页结构和内容,确保语义化。2.CSS通过选择器和属性控制网页样式,使其美观易读。3.JavaScript通过脚本控制网页行为,实现动态和交互功能。

HTMLISNOTAPROGRAMMENGUAGE; ITISAMARKUMARKUPLAGUAGE.1)htmlStructures andFormatSwebContentusingtags.2)itworkswithcsssforstylingandjavascript for Interactivity,增强WebevebDevelopment。

HTML是构建网页结构的基石。1.HTML定义内容结构和语义,使用、、等标签。2.提供语义化标记,如、、等,提升SEO效果。3.通过标签实现用户交互,需注意表单验证。4.使用、等高级元素结合JavaScript实现动态效果。5.常见错误包括标签未闭合和属性值未加引号,需使用验证工具。6.优化策略包括减少HTTP请求、压缩HTML、使用语义化标签等。

HTML是一种用于构建网页的语言,通过标签和属性定义网页结构和内容。1)HTML通过标签组织文档结构,如、。2)浏览器解析HTML构建DOM并渲染网页。3)HTML5的新特性如、、增强了多媒体功能。4)常见错误包括标签未闭合和属性值未加引号。5)优化建议包括使用语义化标签和减少文件大小。

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML的作用是通过标签和属性定义网页的结构和内容。1.HTML通过到、等标签组织内容,使其易于阅读和理解。2.使用语义化标签如、等增强可访问性和SEO。3.优化HTML代码可以提高网页加载速度和用户体验。

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代码” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代码”代码“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML、CSS和JavaScript是Web开发的三大支柱。1.HTML定义网页结构,使用标签如、等。2.CSS控制网页样式,使用选择器和属性如color、font-size等。3.JavaScript实现动态效果和交互,通过事件监听和DOM操作。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

Dreamweaver CS6
视觉化网页开发工具

禅工作室 13.0.1
功能强大的PHP集成开发环境

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。