css - 如何在 :after 元素中居中内容图像
问题描述
我使用带有图像的 :after 元素,效果很好。但我想将 :after 元素(图像)放在页面中心,同时,正常的小元素是左对齐的文本。
该元素是一个显示内联块,但父元素不允许它居中。
CSS
.bold_option_textbox span.bold_help_text:first-of-type>small:after {
content: url(https://cdn.shopify.com/s/files/1/1595/2013/files/PRINT-YOUR-NAME.png?3077);
width: 314px;
height: 176px;
display:inline-block;
text-align:center;
}
HTML
<span class="bold_help_text">
<small>Text Content</small>
</span>
我希望它居中,但它不能居中,因为它是一个 :after 元素并响应其父元素。bold_help_text 项目位于页面中心。
页面元素的实时预览:https ://wild purpose.com/pages/ambassador-package
解决方案
对不起..请尝试显示:块而不是显示:内联块..
CSS
.bold_option_textbox span.bold_help_text:first-of-type>small:after {
display:block;
}
推荐阅读
- azure - Powershell cmdlet 优雅地关闭 azure 虚拟机
- reactjs - 应用程序处于后台状态反应本机时如何清除间隔?
- sql - SQL 查询在我的 JOIN 练习中不起作用
- node.js - 使用 SSO OIDC 身份验证协议从 WSO2 IS 检索 JWT 令牌
- google-apps-script - 如何使用 Mixpanel 的 API 将 Mixpanel 原始数据导出到 Google Sheet?
- c# - 如何将数字从 C# 中的表单发送到 C++ 中的控制台程序
- react-native - 如何在本机反应中路由我的登录屏幕?
- xcode - 为什么在 Git 中切换分支会保留我的更改?
- reactjs - React / Redux - 根据状态变化创建 XHR 请求
- c# - 来自 .net 核心的 Azure ServiceBus 消息无法在 .net 4.6.1 中解析