V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
AntiGameZ
V2EX  ›  问与答

w3.org网站上,这个效果是怎么做D呢

  •  
  •   AntiGameZ · 2011-05-11 15:11:37 +08:00 · 4631 次点击
    这是一个创建于 4755 天前的主题,其中的信息可能已经有所发展或是发生改变。


    源地址是 http://dev.w3.org/html5/spec/Overview.html#the-nav-element

    Firebug看了一下,下面的dl没有什么神奇之处,但是上面凸出来的一块却找不到生成样式的代码,好奇怪。求帮助
    13 条回复    1970-01-01 08:00:00 +08:00
    Hyperion
        1
    Hyperion  
       2011-05-11 15:17:41 +08:00
    红色的那块?... 是带fixed样式的背景图片吧
    xiluo
        2
    xiluo  
       2011-05-11 15:24:27 +08:00
    有可能是html5的新特性就支持呢
    AntiGameZ
        3
    AntiGameZ  
    OP
       2011-05-11 15:26:50 +08:00
    @Hyperion 我也以为是,但是看了并没有设置背景图

    @xiluo 应该不是的
    napoleonu
        4
    napoleonu  
       2011-05-11 15:28:57 +08:00
    .element:before {
    position: absolute;
    z-index: 2;
    top: 0;
    left: -1.15em;
    height: 2em;
    width: 0.9em;
    background: #EEEEFF;
    content: ' ';
    border-style: none none solid solid;
    border-color: #9999FF;
    border-width: 0.25em;
    }
    napoleonu
        5
    napoleonu  
       2011-05-11 15:34:22 +08:00
    h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }

    再结合这一行,就把h4放在了凸出来的那一行了。
    AntiGameZ
        6
    AntiGameZ  
    OP
       2011-05-11 15:40:53 +08:00
    @napoleonu 啊,真是感谢,我来玩玩瞧
    Hyperion
        7
    Hyperion  
       2011-05-11 15:41:07 +08:00
    @napoleonu
    原来指的是这里 =3=

    content: " "; 在div之前添加了一个空格, 原理和after消除浮动一样. 囧
    xhinking
        8
    xhinking  
       2011-05-11 15:44:25 +08:00
    @napoleonu 说的对,Firebug看不到 .element:before ,要直接到源代码里查看。
    napoleonu
        9
    napoleonu  
       2011-05-11 15:55:04 +08:00
    嘿嘿,用Chrome Inspect element很方便。
    fim8
        10
    fim8  
       2011-05-11 16:46:52 +08:00
    看半天没找到楼主说的地方。
    AntiGameZ
        11
    AntiGameZ  
    OP
       2011-05-11 19:31:19 +08:00
    @Hyperion 这个办法相当的tricky啊
    holystrike
        12
    holystrike  
       2011-05-11 20:37:39 +08:00
    @napoleonu 加号表示什么意思啊
    napoleonu
        13
    napoleonu  
       2011-05-11 21:48:44 +08:00
    @holystrike 相邻兄弟选择器(Adjacent Sibling Selectors)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5684 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 08:42 · PVG 16:42 · LAX 01:42 · JFK 04:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.