简体   繁体   English

@media删除top:0; 从风格

[英]@media remove top:0; from style

So I've been wasting a ton of time on this little thing. 所以我在这个小事情上浪费了很多时间。 Hoping someone around here can help me out. 希望有人在这里可以帮助我。

I have a right side navigation panel. 我有一个右侧导航面板。

.navbar_right{
 width: 365px;
 top:0;
 height:100%;
 position:fixed;
 right:0;
}

Now when my website breaks at the width of 1400, I want that same menu placed to the right, but at the bottom instead of the top. 现在,当我的网站以1400的宽度折断时,我希望将相同的菜单放置在右侧,但在底部而不是顶部。 So how do I go about removing top:0; 那么我该如何删除top:0; and adding bottom:0; 并添加bottom:0; instead. 代替。

@media (max-width: 1400px) {
 .navbar_right{
 bottom:0;
 height:40%;
 }
}

I would prefer to be able to use the same container, as the platform I'm working on will be pushing content into the navigation panel, so if I can achieve this small thing - I'll save a lot of resources. 我希望能够使用相同的容器,因为我正在使用的平台会将内容推送到导航面板中,因此,如果我能做到这一点,我会节省很多资源。 Also I'd prefer to avoid jQuery for the same reason. 同样,出于相同的原因,我也希望避免使用jQuery。 Is it possible to stick with this one box, maybe delete a class and add another one? 是否可以坚持使用此框,也许删除一堂课并添加另一堂课?

Set top to its initial value, which is auto : top设置为其初始值,即auto

top: auto;

When you don't know the initial value, you can also use initial : 当您不知道初始值时,也可以使用initial

top: initial;

Or, since top in not inheritable, unset will also reset it to the initial value: 或者,由于top in不可继承,因此未unset也会将其重置为初始值:

top: unset;

Or, if you want to roll back the cascade to the user level, use revert : 或者,如果您想将级联回滚到用户级别,请使用revert

top: revert;

Also see CSS Cascading and Inheritance Level 4 - Explicit Defaulting . 另请参见CSS级联和继承级别4-显式默认设置

.navbar_right{
 width: 365px;
 position:fixed;
 right:0;
}

@media (max-width: 1400px) {
 .navbar_right{
 bottom:0;
 height:40%;
 }
}

@media (min-width: 1399px) {
 .navbar_right{
 top:0;
 height:100%;
 }
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM