css - 如何根据媒体查询更改按钮的文本
问题描述
如果媒体查询是,我想将文本“继续付款”更改为“立即购买”767px
const CheckoutButton = styled(GreenButton)
text-transform: none;
font-family: 'Poppins', Arial, Helvetica, sans-serif;
font-weight: 500;
height: 40px ;
font-size: 1rem;
padding: 6px 20px !important;
margin-left: 100px;
<CheckoutButton disabled={isSubmitting || disabled} onClick={handleSubmit} type="submit">Proceed to Payment</CheckoutButton>
解决方案
可能的解决方案
根据媒体查询添加/删除内联文本元素
解决方案
反应
<CheckoutButton disabled={isSubmitting || disabled} onClick={handleSubmit} type="submit"><span className="desktop-text">Proceed to Payment</span><span className="mobile-text"></span></CheckoutButton>
CSS
.mobile-text {display: none;} @media screen and (max-width: 767px) {.desktop-text {display: none;}.mobile-text {display: inline-block;}
推荐阅读
- python - 如何通过某些功能在 PyQt5 中切换屏幕?
- linux - YOCTO 更改内核版本并选择驱动程序
- django - Django URL 给出错误当前路径 carmodels/Tata/ZEST/XE Petrol 与其中任何一个都不匹配
- android - 基本反应本机应用程序没有在模拟器上显示任何带有应用程序名称的纯文本白屏
- ios - NativeScript Sidekick iOS 代码签名错误:自动生成失败
- ios - 允许用户在 60 层以上购买消耗品应用内购买
- android - 相对布局约束
- swift - 在 UINavigationBar 中看不到 rightBarButtonItem?
- python - 网页抓取动态内容
- three.js - 天空盒 + OrbitControls 问题