HTML5基础加强css样式篇 (高仿百度新闻热门文章窗口)(六)
2017-03-15 10:01
477 查看
1.静态布局:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>高仿百度新闻热门文章</title> <style type="text/css"> html,body,div{ margin: 0px; padding: 0px; } #tables{ width: 350px; margin: 0px auto; position: relative; margin-top: 60px; border-top: 1px solid #eeeeee; } .tab{ width: 45px; height: 28px; position: absolute; top: -30px; border: 1px solid #eeeeee; text-align: center; line-height: 28px; } .tab_left{ right: 45px; border-right: 0px; vertical-align: middle; border-bottom: 1px white solid; } .tab_right{ right: 0px; vertical-align: middle; } </style> </head> <body> <div id="tables" > <div class="tab tab_left">日榜</div> <div class="tab tab_right">周榜</div> <div class="tabcontent" >日榜66666</div> <div class="tabcontent" >周榜77777</div> </div> </body> </html>
2.添加逻辑:
所需精灵图如下:可以随意制作
代码如下:注:细节自己调下就好
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>高仿百度新闻热门文章</title> <style type="text/css"> html,body,div{ margin: 0px; padding: 0px; } ul{ list-style: none; margin: 0px; padding: 0px; } #tables{ width: 350px; margin: 0px auto; position: relative; margin-top: 60px; border-top: 1px solid #eeeeee; } .tab{ width: 45px; height: 28px; position: absolute; top: -30px; border: 1px solid #eeeeee; text-align: center; line-height: 28px; } .tab_left{ right: 45px; border-right: 0px; vertical-align: middle; } .tab_right{ right: 0px; vertical-align: middle; } .show_hot{ border-bottom: 2px white solid; } .tabcontent{ position: absolute; top:0px; left: 0px; background-color:white ; } #contentday{ z-index: 10; } #contentweek{ z-index: 1; } .titlesimg{ display: inline-block; width: 17px; height: 18px; vertical-align: middle; } a{ text-decoration: none; } #one2{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -18px; } #one3{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -36px; } #one4{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -54px; } #one5{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -72px; } #one1{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 0; } #two1{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 0; } #two2{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -18px; } #two3{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -36px; } #two4{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -54px; }#two5{ background:#fff url("img/icon-nums_7f1b1d2.png") no-repeat 0 -72px; } .tab_title{ height: 28px; position: absolute; top: -30px; text-align: center; line-height: 28px; left: 0px; } </style> </head> <body> <div id="tables" > <div class="tab tab_left show_hot" id="hotday">日榜</div> <div class="tab tab_right" id="hotweek">周榜</div> <div class="tab_title">热门文章</div> <div class="tabcontent" id="contentday"> <ul> <li ><i id="one1" class="titlesimg"></i><a href="javascript:;" title="完整的标题... ....">日榜内容</a></li> <li ><i id="one2" class="titlesimg"></i><a href="javascript:;">日榜内容</a></li> <li ><i id="one3" class="titlesimg"></i><a href="javascript:;">日榜内容</a></li> <li ><i id="one4" class="titlesimg"></i><a href="javascript:;">日榜内容</a></li> <li ><i id="one5" class="titlesimg"></i><a href="javascript:;">日榜内容</a></li> </ul> </div> <div class="tabcontent" id="contentweek" > <ul> <li ><i id="two1" class="titlesimg"></i><a href="javascript:;">周榜内容</a></li> <li ><i id="two2" class="titlesimg"></i><a href="javascript:;">周榜内容</a></li> <li ><i id="two3" class="titlesimg" ></i><a href="javascript:;">周榜内容</a></li> <li ><i id="two4" class="titlesimg"></i><a href="javascript:;">周榜内容</a></li> <li ><i id="two5" class="titlesimg"></i><a href="javascript:;">周榜内容</a></li> </ul> </div> </div> </body> <script type="text/javascript"> var tables=document.getElementById("tables"); var hotday=document.getElementById("hotday"); var hotweek= document.getElementById("hotweek"); var contentday=document.getElementById("contentday"); var contentweek=document.getElementById("contentweek"); tables.onmouseover=function(even){ var tar= even.target; if(tar.id=="hotday"){ hotday.style.borderBottom="2px white solid"; hotweek.style.borderBottom="1px solid #eeeeee"; contentday.style.zIndex=10; contentweek.style.zIndex=1; }else if(tar.id=="hotweek"){ hotweek.style.borderBottom="2px white solid"; hotday.style.borderBottom="1px solid #eeeeee"; contentday.style.zIndex=1; contentweek.style.zIndex=10; } } </script> </html>
相关文章推荐
- HTML5基础加强css样式篇(css过渡属性简写,cubic-bezier过度曲线函数使用)(二十)
- HTML5基础加强css样式篇(多媒体选择器)(十七)
- HTML5基础加强css样式篇(css过渡属性的隐式过渡问题)(二十二)
- HTML5基础加强css样式篇(css过度覆盖问题)(二十一)
- HTML5基础加强css样式篇(animation填充属性:animation-fill-mode,播放控制属性:animation-play-state,播放顺序设置,)(三十一)
- HTML5基础加强css样式篇(css属性transform 函数(2D)时钟)(二十六)
- HTML5基础加强css样式篇(常用伪元素选择器after,before)(十五)
- HTML5基础加强css样式篇(属性选择器)(十四)
- HTML5基础加强css样式篇(css属性transform 函数(2D)的scale(),transform-origin,skew(),translate(),rotate() )(二十四)
- HTML5基础加强css样式篇(float补充,清除浮动解决高度塌陷问题,定位补充)(一)
- HTML5基础加强css样式篇(DOM的属性操作(对class属性值的操作 setAttribute,removeAttribute,classlist:remove,add,toggle))(七)
- HTML5基础加强css样式篇(font-family,font-size, font-style,font-variant, font-weight , font 简写属性 )(五)
- HTML5基础加强css样式篇(伪元素first-letter,first-line,selection和css计数函数counter,counters)(十六)
- HTML5基础加强css样式篇(结构化伪类选择器:nth-of-type)(十一)
- HTML5基础加强css样式篇(css属性border详解(一))(三十三)
- HTML5基础加强css样式篇(animation属性animation-name,animation-delay,animation-duration,等)(三十)
- HTML5基础加强css样式篇(target目标伪类选择器)(九)
- HTML5基础加强css样式篇(css过度效果:界面的浮层遮罩和消失)(十九)
- HTML5基础加强css样式篇(css属性transform 函数(3D)transform-style)(二十五)
- HTML5基础加强css样式篇(checked状态伪类和清除默认样式)(十三)