css - 使用样式化组件在小型设备上隐藏按钮
问题描述
我有一个 React 应用程序,我想在从小型设备查看时隐藏标题中的某些按钮。我通过 Styled Components 对所有内容进行样式化。
我正在尝试进行这样的媒体查询,以在屏幕大于 700px 时隐藏按钮:
export const BigScreenButton = styled(Button)`
color: white !important;
border: 2px solid white !important;
border-radius: 3px !important;
padding: 0 10px;
margin-left: 10px !important;
@media screen and (max-width: 700px) {
display: none;
}
`;
但是,这不起作用(我可以从 CSS 的角度理解为什么)...我正在尝试查找 Styled Component 相关示例,但没有成功。
解决方案
这应该可以正常工作,除了:
我正在尝试进行媒体查询...如果屏幕大于 700 像素,则隐藏按钮:
你应该使用min-width
@media screen and (min-width: 700px) {
display: none;
}
另外,相关文章。
推荐阅读
- java - 如果我不需要可滚动功能,请替换 RecyclerView?
- python - Tensorflow Object detection api - 具有多个边界框问题的预测
- python - Pandas 中一个特定列的名称没有改变
- flutter - 如何解决flutter dropdownButtonFormField动态选择检查dropdownButton的值
- php - 跨php页面的会话变量不一样
- c++ - 标准差的输出为 NaN - C++
- python - 为什么使用 OneHotEncoding 可以更好地执行 NN?
- reactjs - 使用 API 身份验证反应私有路由验证
- python - Sympy 向量加法返回 sympy.core.add.Add 而不是 sympy.vector.vector.VectorAdd
- processing - 如何使事件每 8 帧和最后两帧(处理)发生一次?