z-index与css多背景图
来源:互联网 发布:mac cs1.6 编辑:程序博客网 时间:2024/05/16 07:11
在这个周的实习中需要实现如下一个功能
即左上角的排名数字是可以随便填的,左上角的红色区域,中间的点击图标是可以通过css可以修改,这个需要通过z-index来设置各个图层的深度,具体代码如下,大家可以参考
<html> <head> <style type="text/css"> .wrap{ width: 240px; height: 240px;margin: 0px auto; background-color: #ccc;overflow: hidden; } .top_left{ z-index: 100; width: 48px; height: 48px; background: url(paihang.png); top:-60px; left:0px; position: relative; } .center{ z-index: 100; width: 48px; height: 48px; background: url(dianji.png); top:-20px; left: 90px; position: relative; } .paiming{ z-index: 101; top: -15px; left:10px; position: relative; } img{ width:240px;height: 240px;top: -155px;left:0px;position: relative; } </style> </head> <body> <div class="wrap"> <div class="paiming"><h3>1</h3></div> <div class="top_left"></div> <div class="center"></div> <img src="1.jpg" alt=""> </div> </body>大家可以发现其中,红色区域和点击图标是分开设置,但其实完全可以通过一个图层来实现,不过这就需要使用多背景图了。关键代码:.box{ z-index: 100; width: 240px; height: 240px; top: -58px; position: relative; background: url(paihang.png) no-repeat left top, url(dianji.png) no-repeat center center; } <html> <head> <style type="text/css"> .wrap{ width: 240px; height: 240px;margin: 0px auto; background-color: #ccc;overflow: hidden; } .box{ z-index: 100; width: 240px; height: 240px; top: -58px; position: relative; background: url(paihang.png) no-repeat left top, url(dianji.png) no-repeat center center; } .paiming{ z-index: 101; top: -15px; left:10px; position: relative; } img{ width:240px;height: 240px;top: -301px;left:0px;position: relative; } </style> </head> <body> <div class="wrap"> <div class="paiming"><h3>1</h3></div> <div class="box"></div> <img src="1.jpg" alt=""> </div> </body>
具体源文件在:http://pan.baidu.com/share/link?shareid=2881317635&uk=1998297189
- z-index与css多背景图
- css中z-index与position
- CSS 定位(position 与 z-index)
- CSS z-index
- css z-index
- css中z-index
- css:z-index
- css z-index 不起作用
- CSS z-index 属性
- CSS z-index 属性
- css z-index详解
- CSS z-index 属性
- css之z-index
- CSS z-index 属性
- CSS z-index 属性
- css:z-index总结
- CSS:z-index
- CSS z-index 属性
- 异常处理学习笔记
- C++_标准数组-向量
- Flex调用webService读取SQL数据库
- 黑马程序员—HTML+CSS系列 (一)
- 考考你的逻辑推理能力
- z-index与css多背景图
- 什么是图灵机
- 黑马程序员—HTML+CSS系列 (二)
- error C2664: 'DeleteFileW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
- 潘石屹《我用一生去寻找》精彩段落总结
- epoll/linux支持的最大连接数,文件描述符不够报错信息是too many open files的解决办法
- 用DOM创建添加节点
- ubuntu 12.04安装RabbitVCS
- 《软件调试》读书笔记一