超有意思的 html 面 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
honk
V2EX    分享发现

超有意思的 html 面

  •  2
     
  •   honk 2020-10-19 22:13:27 +08:00 4795 次点击
    这是一个创建于 1888 天前的主题,其中的信息可能已经有所发展或是发生改变。
    17 条回复    2020-10-20 19:28:34 +08:00
    ashine
        1
    ashine  
       2020-10-19 22:21:56 +08:00
    没发现哪里特别的,不就是几个 css 的特性吗
    wanacry
        2
    wanacry  
       2020-10-19 22:23:04 +08:00 via iPhone
    有意思的点在哪?
    opengps
        3
    opengps  
       2020-10-19 22:26:32 +08:00   1
    谁解读下用法,html 代码可见但是却不影响只选中文本,我是第一次见
    JmmBite
        4
    JmmBite  
       2020-10-19 22:30:40 +08:00
    ```css
    html::before {content:'<html>'}
    html::after {content:'</html>'}
    head::before {content:'<head>'}
    head::after {content:'</head>'}
    title::before {content:'<title>'}
    title::after {content:'</title>'}
    body::before {content:'<body>'}
    body::after {content:'</body>'}
    h1::before {content:'<h1>'}
    h1::after {content:'</h1>'}
    h2::before {content:'<h2>'}
    h2::after {content:'</h2>'}
    p::before {content:'<p>'}
    p::after {content:'</p>'}
    pre::before {content:'<pre>'}
    pre::after {content:'</pre>'}
    code::before {content:'<code>'}
    code::after {content:'</code>'}
    a::before {content:'<a>'}
    a::after {content:'</a>'}
    aside::before {content:'<aside>'}
    aside::after {content:'</aside>'}
    blockquote::before {content:'<blockquote>'}
    blockquote::after {content:'</blockquote>'}
    em::before {content:'<em>'}
    em::after {content:'</em>'}
    strong::before {content:'<strong>'}
    strong::after {content:'</strong>'}
    ```
    xycool
        5
    xycool  
       2020-10-19 22:31:06 +08:00
    @opengps #3 套娃用法,仔细查看一个标签的样式就能发现,比如:
    ```h1::before {content:'<h1>'}
    h1::after {content:'</h1>'}```
    finian
        6
    finian  
       2020-10-19 22:31:43 +08:00
    有意思的地方就是源码和展示的内容是一样的
    yuzo555
        7
    yuzo555  
       2020-10-19 22:33:31 +08:00   2
    用 CSS 的 content 属性实现在常见元素的 before 和 after 加上文字开关;
    (@opengps 而 content 属性显示内容是无法被选中的)

    然后给 * 所有元素加上 display:block,这样就实现了 <body> 内部的 <style> 内部内容也能显示出来。
    des
        8
    des  
       2020-10-19 22:34:29 +08:00
    这不算有意思吧,来看看这个? sojo.im
    honk
        9
    honk  
    OP
       2020-10-19 22:43:56 +08:00 via Android
    @des 闪瞎了我的眼
    martinsu
        10
    martinsu  
       2020-10-20 00:17:00 +08:00
    @des Edge 提示风险
    kaiki
        11
    kaiki  
       2020-10-20 00:29:46 +08:00
    可惜 link 用的 attr,实际上是在 css 里面把这个 link 重写了一遍
    sinv
        12
    sinv  
       2020-10-20 01:50:17 +08:00 via Android
    @des Hacked by RR
    Mutoo
        13
    Mutoo  
       2020-10-20 05:05:25 +08:00 via iPhone
    我的主页也是类似的效果,只不过是 Javascript 实现: https://mutoo.im
    abcdabcd987
        14
    abcdabcd987  
       2020-10-20 06:29:03 +08:00
    Ritter
        15
    Ritter  
       2020-10-20 09:39:10 +08:00
    菜狗有个问题 这样每个标签前后都加 before after 不累吗 还是有工具可以批量生成
    honk
        16
    honk  
    OP
       2020-10-20 13:01:14 +08:00 via Android
    @Ritter 只是 CSS 特性的取巧式利用。
    真实项目不可能这样用的
    gxgxxn
        17
    gxgxxn  
       2020-10-20 19:28:34 +08:00
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2674 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 09:02 PVG 17:02 LAX 01:02 JFK 04:02
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86