纯css 实现tab效果
来源:互联网 发布:iphone铃声助手 mac 编辑:程序博客网 时间:2024/04/30 18:15
原理:
1、radio 与a 重叠,
2、radio zindex属性比a大,
3、radio透明
参考 http://www.imooc.com/video/7144
<html><head> <style type="text/css"> .nav { position: fixed; bottom: 10px; width: 100%; height: 50px; } input, a { position: absolute; width: 20%; height: 100%; } input { z-index: 100; opacity: 0; } a { text-decoration:none; text-align: center; background: yellow; line-height: 50px; } .nav_item1, .nav_item1 + a { left: 0%; } .nav_item2, .nav_item2 + a { left: 20%; } .nav_item3, .nav_item3 + a { left: 40%; } .nav_item4, .nav_item4 + a { left: 60%; } .nav input:checked + a { background-color: #ff0000; font-size: 26px; } </style></head><body><div class="nav"> <input type="radio" name="nav_radio" checked="checked" class="nav_item1"> <a href="#">aa</a> <input type="radio" name="nav_radio" class="nav_item2"> <a href="#">bb</a> <input type="radio" name="nav_radio" class="nav_item3"> <a href="#">cc</a> <input type="radio" name="nav_radio" class="nav_item4"> <a href="#">dd</a></div></body></html>
<html><head> <style type="text/css"> .nav { position: relative; } .nav-item { display: inline-block; width: 20%; height: 50px; margin-left: 10px; position: relative; } input { position: absolute; top: 0px; left: 0px; width: 100%; z-index: 100; height: 100%; opacity: 0; } a { position: absolute; top: 0px; width: 100%; height: 100%; text-align: center; background: yellow; line-height: 50px } .nav input:checked + a { background-color: #ff0000; font-size: 26px; } </style></head><body><div class="nav"> <div class="nav-item"> <input type="radio" name="nav_radio" checked="checked"> <a href="#">aa</a> </div> <div class="nav-item"> <input type="radio" name="nav_radio"> <a href="#">aa</a> </div> <div class="nav-item"> <input type="radio" name="nav_radio"> <a href="#">aa</a> </div> <div class="nav-item"> <input type="radio" name="nav_radio"> <a href="#">aa</a> </div></div></body></html>
html简单,css就要复杂点,
html 复杂,css就能简单点,
html 简单至上,后台人员只要看html,当然结构简单更好,
0 0
- 纯css 实现tab效果
- 纯 css实现tab切换效果
- 纯css实现tab切换
- 纯CSS实现tab切换
- 纯css实现tab切换
- 纯CSS实现翻页效果
- 纯CSS实现手风琴效果
- 纯CSS实现手风琴效果
- 纯css实现粒子效果
- 纯css实现阴影效果
- 纯css实现进度条效果
- 纯css实现进度条效果
- 纯css实现进度条效果
- 纯css实现进度条效果
- 纯css实现进度条效果
- 纯css实现进度条效果
- 纯 CSS 实现波浪效果!
- 纯 CSS 实现 tab 页切换
- 开源、高效、跨平台:深剖Google FlatBuffers工作原理
- Django——Xadmin内置插件
- nyoj71独木舟上的旅行
- Android中View的加载和显示
- Python在终端不换行打印输出
- 纯css 实现tab效果
- 捕获input 文本框内容改变的事件(onchange,onblur,onPropertyChange比较)
- C#(源码)操作Excel大全2
- C# Redis API
- spring4泛型初探----一个小例子
- 获取新浪微博内容和评论
- 对指针进行初始化中的若干问题的思考与反思
- Java中的枚举与values()方法
- greenDao的使用---重点来啦 实现ORM连表 增删改查 颤抖吧凡人