博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
advanced_CSS_5_2
阅读量:7105 次
发布时间:2019-06-28

本文共 3796 字,大约阅读时间需要 12 分钟。

hot3.png

/*The first things you want to do are remove the default bullets and zero down the margin andpadding:*/ul.nav {margin: 0;padding: 0;list-style-type: none;}/*You can then start layering on the graphical styling. In this case, I’m giving my navigation menu alight green background and a dark green border. I’m also going to set the width of my navigate listin ems.*/ul.nav {margin: 0;padding: 0;list-style-type: none;width: 8em;background-color: #8BD400;border: 1px solid #486B02;}/*Rather than style the list items, styling the enclosed anchor links provides better cross-browsercompatibility. To create a button-like hit area, you simply set the display property of the anchorsto block. The anchor links will then expand to take up the available space, which in this case isdetermined by the width of the list. You could set the width of the anchors explicitly, but I’ve foundsetting the width of the parent list makes for more maintainable code. The last couple of rules arejust stylistic, setting the color of the link text and turning off the underlines.*/ul.nav a {display: block;color: #2B3F00;text-decoration: none;}/*To create the beveled effect on the menu items, you need to set the top border to be lighter thanthe background color and the bottom border slightly darker. At this point, you can also drop in abackground image to use as an icon.hint:Ideally, I would have set the positioning of my arrow to be 10 pixels from theleft-hand edge of the anchor. However, the CSS specification doesn’t allow themixing of units, so I’ve used a percentage instead. In reality, most browsersaccept mixed units, and I think this is one of several instances where thespecification is wrong;*/ul.nav a {display: block;color: #2B3F00;text-decoration: none;border-top: 1px solid #E4FFD3;border-bottom: 1px solid #486B02;background: url(./img/arrow.gif) no-repeat 5% 50%;padding: 0.3em 1em;}/*With all the borders stacked one on top of the other, you’ll notice that the bottom border on thefinal link doubles up with the bottom border on the list. In this instance, I’m going to take thesimple option and remove the bottom border from the list. However in situations where this isn’tpossible, the addition of a class on the first or last list item can allow you to remove the borderdirectly. In the future, you’ll also be able to use the :last-child pseudo class, but for the timebeing, browser support is limited.*/ul.nav .last a {border-bottom: 0;}/*The list now looks like a stylish vertical navigation bar. To complete the effect, the last thing youneed to do is apply the :hover, :focus, and :selected states. To do this, simply change thebackground and text colors. You could also experiment with changing the border colors to createa depressed button type effect. These styles are applied to the anchor links when the user hoversover them. They are also applied to any anchors that have a class of selected applied to theirparent list item.*/ul.nav a:hover,ul.nav a:focus,ul.nav .selected a {color: #E4FFD3;background-color: #6DA203;}/*This technique should now work in all the major browsers except IE 6 and below for Windows.Unfortunately, IE6 inexplicably adds extra space above and below the list items. To fix this bug,you need to set the display property on the list items to inline:*/ul.nav li {display: inline: /* :KLUDGE: Removes large gaps in IE/Win */}/*And there you have it: a styled vertical nav bar, complete with rollovers.*/
  • Home1
  • About
  • Our Services
  • Our Work
  • News
  • Contact
  • AHA

    AHA

    转载于:https://my.oschina.net/LosersAFC/blog/213260

    你可能感兴趣的文章
    BZOJ5415 [NOI2018] 归程
    查看>>
    Gridview, ObjectDataSource Making life easy
    查看>>
    P2835 刻录光盘
    查看>>
    转:Vim实战指南(五):文本替换
    查看>>
    springmvc.xml文件的位置和命名
    查看>>
    $.getJSON中文乱码
    查看>>
    [转] C语言字节对齐详解
    查看>>
    iOS XMPPFramework 环境配置
    查看>>
    正则表达式总结
    查看>>
    [EF]vs15+ef6+mysql这个问题,你遇到过么?
    查看>>
    [Html5]sessionStorage和localStorage的区别
    查看>>
    遍历特定类型子对象
    查看>>
    二逼平衡树 Tyvj 1730 BZOJ3196 Loj#106
    查看>>
    ORA-12541: TNS: 无监听程序 怎么解决
    查看>>
    自定义UIButton--iPhone按钮控件点击效果写法
    查看>>
    HDOJ_ACM_CUP
    查看>>
    陶哲轩实分析习题8.5.11
    查看>>
    软件工程随堂小作业——(C++)
    查看>>
    搭建个人专用的谷歌搜索镜像站---学习笔记
    查看>>
    三步轻松打造微信聊天机器人(附源码)
    查看>>