Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 css 文件,我希望他仅在视口为 1024 或更高时才使用。
如何声明我的 css 文件仅加载并基于我将决定的视口?
您可以使用媒体属性。
<link rel="stylesheet" media="screen and (min-device-width: 1024px)" href="style.css" />
另一种解决方案:
<style> @media only screen and (min-device-width: 1024px) { Whatever you want for css... } </style>