简体   繁体   English

在窗口调整大小上消失固定的div

[英]Disapearing fixed div on window resize

The fixed panel on http://mondaybynoon.com/ disappears, when the window has a width<960. 当窗口的宽度<960时, http: //mondaybynoon.com/上的固定面板消失。 No JS is used for that. 没有使用JS。 Can someone explain, how it is implemented? 有人可以解释一下它是如何实现的吗?

He is use media query for that responsive website. 他正在对该响应网站使用media query

You can define in HTML like this: 您可以像这样在HTML定义:

<link rel='stylesheet' media='screen and (max-width: 900px)' href='css/medium.css' />

OR You can define in CSS like this: 或者您可以在CSS定义如下:

@media screen and (max-width: 900px){
  body {
    background: #ccc;
  }
} 

check these articles for more http://css-tricks.com/css-media-queries/ , http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/ 检查这些文章以了解更多http://css-tricks.com/css-media-queries/http://coding.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/

They use the @media rule. 他们使用@media规则。

Snippet from their CSS: 他们的CSS片段:

@media (max-width:950px) {
    #sidebar { display:none; }
    #content { margin-left:20px; }
    ...
}

Documentation: http://www.w3.org/TR/css3-mediaqueries/#width 文档: http : //www.w3.org/TR/css3-mediaqueries/#width

They use css to do this. 他们使用CSS执行此操作。 They have rules that say when the browsers width is at this certain width implement this css. 他们有规则说,当浏览器的宽度达到此特定宽度时,将执行此CSS。

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

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