CSS“内容”不管用 [英] CSS "content" is not working

查看:85
本文介绍了CSS“内容”不管用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望通过CSS添加段落的文字,而不是添加到HTML中,因为这是一个随网站响应而改变的主题。



现在我不能让它工作,我想知道是否有什么问题的CSS?



另外,这是唯一的方法可以做到这一点纯HTML和CSS),还是有另一种方法来定位文本并改变它的每一个决议?



HTML:

 < p class =title>< / p> 

CSS:

  p.title {
width:auto;
height:auto;
职位:亲属;
float:left;
明确:无;
margin:40px 0 0 0;
padding:0;
display:block;
font-family:'Fjalla One',sans-serif;
font-weight:400;
font-size:36px;
颜色:#d76e50;颜色:rgba(215,92,52,0.9);
cursor:default;
内容:TITLE GOES HERE;
}


解决方案

CSS content 属性只能用于 :: before :: after 伪-elements。例如,你可以通过创建一个仅在 :: after 之后具有样式的子元素来解决这个问题,并且还包含 content 依赖媒体查询解析的文本的属性。


I would like to add the text for the paragraph through CSS rather then in the HTML, because it's a subject to change with the responsiveness of the website.

Now I can't get it to work, and I am wondering if there is something wrong with the CSS?

Also, is this the only way this could be done (with pure HTML and CSS) or is there another way to target a text and change it with every resolution?

HTML:

<p class="title"></p>

CSS:

p.title {
        width: auto;
        height: auto;
        position: relative;
        float: left;
        clear: none;
        margin: 40px 0 0 0;
        padding: 0;
        display: block;
        font-family: 'Fjalla One', sans-serif; 
        font-weight: 400; 
        font-size: 36px;
        color: #d76e50; color: rgba(215, 92, 52, 0.9);
        cursor: default;
        content:"TITLE GOES HERE";
}

解决方案

The CSS content property can only be used with ::before and ::after pseudo-elements. You could work around this by creating a child element which only has styles on ::after for example, and also includes the content property for the text that is dependent on resolution via media queries.

这篇关于CSS“内容”不管用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆