简体   繁体   English

屏幕宽度小于X时是否有可能禁用继承?

[英]is there a possibility to disable inheritance while screen width is less than X?

I am making simple website with my friend and he did 'sticky' header which decreases for example font-size while scrolling but we do not want these classes to "work" when website is in mobile version. 我正在和我的朋友制作一个简单的网站,他做了“粘性”标题,例如,在滚动时会减小字体大小,但是当网站处于移动版本时,我们不希望这些类“起作用”。 Is there a possibility to turn that inheritance off when our website width is less than 400px for example? 例如,当我们的网站宽度小于400px时,是否可以关闭该继承? I mean we have media queries but we do not want this code to start working when website is in media screen max width 400px mode is it even possible? 我的意思是我们有媒体查询,但是当网站处于媒体屏幕最大宽度为400px模式时,我们不希望此代码开始工作吗? thanks a lot for all responses. 非常感谢您的所有回复。

 /* I want this to work when screen is bigger than 1024px */ header.sticky a { padding: 0px 0px 20px 0px; font-size: 18px; font-weight: 100; transition: .5s; font-weight: 500; } header.sticky { background-color: RGB(105,0,0,0.8); transition: .5s; } header a.active { color: #E6AF2E; } header.sticky .logo{ margin: 0; transition: .5s; font-size: 40px; } /* that was standard header */ header{ font-weight: 500; background: transparent; text-align: center; position: fixed; z-index: 999; width: 100%; transition: .5s; } header h1{ font-family: 'Kaushan Script', cursive; color: #fff; font-size: 48px; letter-spacing: 2px; transition: 0.3s; transition: .5s; } header h1:hover{ color: #E6AF2E; cursor: pointer; } 

You can use, instead of max-width: 400px; 您可以使用而不是max-width: 400px; , min-width: 1024px; min-width: 1024px; for the media query. 用于媒体查询。

It looks like you just want to wrap the first part in a media query? 看来您只想将第一部分包装在媒体查询中?

eg: 例如:

 /* I want this to work when screen is bigger than 1024px */ @media screen and (min-width: 1024px){ header.sticky a { padding: 0px 0px 20px 0px; font-size: 18px; font-weight: 100; transition: .5s; font-weight: 500; } header.sticky { background-color: RGB(105,0,0,0.8); transition: .5s; } header a.active { color: #E6AF2E; } header.sticky .logo{ margin: 0; transition: .5s; font-size: 40px; } } /* that was standard header */ header{ font-weight: 500; background: transparent; text-align: center; position: fixed; z-index: 999; width: 100%; transition: .5s; } header h1{ font-family: 'Kaushan Script', cursive; color: #fff; font-size: 48px; letter-spacing: 2px; transition: 0.3s; transition: .5s; } header h1:hover{ color: #E6AF2E; cursor: pointer; } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果屏幕宽度小于 x,则调整 iFrame 的大小 - Resize iFrame if screen width is less than x 如果屏幕宽度小于960像素,则将屏幕宽度添加到类中 - Add width of the screen to a class if screen width is less than 960 px 如果屏幕宽度小于特定宽度,则隐藏导航栏的某些链接 - Hide certain links of a navbar if the screen width is less than a certain width 元视口仅适用于移动设备(屏幕宽度小于640) - meta viewport only for mobile (screen width less than 640) 汉堡图标在小于500像素的屏幕上没有显示? - Hamburger icon not showing on screen width less than 500px? 如果屏幕宽度小于800(移动设备),则完全删除div - Completely remove a div if screen width is less than 800 (mobile device) 宽度小于X像素时更改布局 - Change layout when width is less than X pixels 如何设置宽度 <hr/> 在CSS中X的像素数小于宽度:auto? - How to set width of a <hr/> in CSS to X number of pixels less than the width:auto? 为什么@media only screen and (min-width: 768px) 也适用于屏幕宽度小于768px - why @media only screen and (min-width: 768px) also apply for screen width less than 768px 宽度小于屏幕分辨率。 但是仍然显示水平滚动条。 可能是什么原因? - Width less than screen resolution. But still showing horizontal scroll bar. what can be the reason?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM