如何使移动设备的 react-icons 图标尺寸更小?我知道像素不是一个好方法,但我应该怎么做呢?
import { FaSearch, FaFacebook, FaInstagram, FaUserCog, FaUserTimes } from "react-icons/fa";
<FaSearch
color="#023373"
size="30px" />
如何使移动设备的 react-icons 图标尺寸更小?我知道像素不是一个好方法,但我应该怎么做呢?
import { FaSearch, FaFacebook, FaInstagram, FaUserCog, FaUserTimes } from "react-icons/fa";
<FaSearch
color="#023373"
size="30px" />
您可以@media
在您的情况下使用查询。向您的图标组件添加一个类并为移动设备宽度编写媒体查询。
<FaSearch color="#023373" className="SearchIcon" />
在您的 CSS 中,执行此操作
.SearchIcon{
font-size: 40px;
}
@media only screen and (max-width: 400px) {
.SearchIcon {
font-size: 20px;
}
}
我使用Stackblitz创建了一个工作示例
这是@media
针对不同设备宽度的所有查询的列表。
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}