css - 媒体查询进行更改时不显示伪元素
问题描述
我有 :before 和 :after 伪元素。当媒体规则的屏幕宽度为 max-width:760px 时,我需要更改这些。
当最大宽度为 760 或 > 时,我应该看到不同的图形但相同的 :before 和 :after 文本内容。
我看到了新图形,但没有看到 :before 和 after 元素显示。
我尝试在 @media all 和 (max-width:760px) 下的 CSS 中添加 :before 和 after 伪元素,但没有任何成功。
有谁知道为什么这不显示?
CSS
#infoGraph::before {width:100%; content:"Did you know..."; line-height:3rem; font-weight:bold; font-variant-caps:all-small-caps; font-size:1.4rem; margin-top:1.5rem;}
#infoGraph::after {width:100%;content:"Full text here..."; font-style:italic; font-size: 0.8rem}
#infoGraph {width:100%}
#infoGraph img {width:100%}
@media all and (max-width:760px){
#infoGraph{content: url('/site_images/new-graphic.png');}
}
解决方案
您缺少媒体规则周围的括号:
@media all and (max-width:760px) {
#infoGraph{content: url('/site_images/new-graphic.png');}
}
推荐阅读
- architecture - 上下游服务
- html - 如何使css渐变全屏?它不会显示在样式化的 div 后面
- nativescript - Nativescript 8 和 Angular 12 延迟加载 => nsRouterLinkActive 不添加活动类
- javascript - 避免在每个请求中使用 Axios 在 Vue 中响应错误时进行处理
- google-bigquery - 如何在 BigQuery 中使用 $ thru JSON_EXTRACT 获取键的值
- amazon-web-services - 联合 google 登录问题(aws amplify 和 Vue js)
- java-8 - SQLException SQL 状态 [99999];错误代码 [17068]
- vue.js - 打包包含 Vuetify 的 Vue 组件后,Vuetify 不会在另一个项目中渲染
- angular - 以反应形式选择不显示任何内容
- server - 有没有办法将上传的数据(例如图像文件)发送到本地服务器?