加入收藏 | 设为首页 | 会员中心 | 我要投稿 东莞站长网 (https://www.0769zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 编程要点 > 语言 > 正文

CSS的content属性都有哪些使用,你了解多少?

发布时间:2022-04-11 17:17:05 所属栏目:语言 来源:互联网
导读:这篇文章小编给大家分享的是CSS的content属性的相关使用,content属性一般用于::before、::after伪元素中,用于呈现伪元素的内容。很多时候,content属性值我们用的最多的就是给个纯字符,其实它还有很多值可供选择文中示例介绍的很详细,感兴趣的朋友可以了
    这篇文章小编给大家分享的是CSS的content属性的相关使用,content属性一般用于::before、::after伪元素中,用于呈现伪元素的内容。很多时候,content属性值我们用的最多的就是给个纯字符,其实它还有很多值可供选择文中示例介绍的很详细,感兴趣的朋友可以了解看看,下面让我们一起来学习一下吧!
 
    1、插入纯字符
 
<style>
    *{margin: 0;padding: 0;box-sizing: border-box;}
    li{list-style: none;}
    .content{
        position: relative;padding: 10px;
        border: 1px solid #666;margin: 10px;
    }
    .content.only-text::before{
        content: '插入纯字符';
    }
</style>
 
<body>
    <h1>1、插入纯字符</h1>
    <div class="content only-text"></div>
</body>

    2、插入元素属性
 
<style>
    *{margin: 0;padding: 0;box-sizing: border-box;}
    li{list-style: none;}
    .content{
        position: relative;padding: 10px;
        border: 1px solid #666;margin: 10px;
    }
    .content.fill-dom-attr::before{
        content: attr(data-title);
    }
</style>
 
<body>
    <h1>3、插入元素属性</h1>
    <div class="content fill-dom-attr" data-title="我是.fill-dom-attr元素的 data-title 属性值"></div>
</body>。

(编辑:东莞站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读