响应式布局主要用来当遇到不同屏幕大小的时候,我们的网页还可以以比较友好的方式显示给用户。主要有4中类型的屏幕,
1、宽屏的台式机
2、便携式的笔记本
3、平板电脑
4、智能手机
下图是不同设备中同一个网页的不同显示效果
响应式布局主要用到的css中media query,它可以判断当前屏幕的尺寸。
有关css media query 谷歌一下就可以找到详细资料
其他的就是根据不同屏幕宽度来实现我们的布局了。
常见的有导航栏的响应式布局,表格的自使用,图像的自适用,网格多列布局的自适应等。
下面我们来演示一个机遇多列布局的响应式布局。
当屏幕尺寸在 10em(160px)<width <42em(672px)时候,我们让第一列独占一行,
其他2列浮动,占据一行,同时设置它的字体大小和颜色(区分)
42em(672px0 ) <width < 55em(880px)
3列都浮动,同时宽度按照 2:1:1来分配
width > 75em (1200px)
3列都浮动,但我们把字体的大小设置大一点。
从上面的3副图片可以看出来,我们页面确实可以根据不同的屏幕大小来自使用显示内容了。
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>grid responsive layout</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script> <style> /* 1st breakpoint - Float B and C, leave A full width on top */ /* 1em=16px */ @media all and (max-width: 42em) and (min-width: 10em)) { /*672px*/ .rwd-example { overflow: hidden; /* Use this or a "clearfix" to give the container height */ } .rwd-example .ui-body { min-height: 14em; } .rwd-example .ui-block-b, .rwd-example .ui-block-c { float: left; width: 49.95%; } .rwd-example .ui-body { font-size: 0.8em; color: red; } } /* 2nd breakpoint - Float all, 50/25/25 */ @media all and (min-width: 55em) { /*880px*/ .rwd-example .ui-body { min-height: 18em; } .rwd-example .ui-body { font-size: 100%; color: green; } .rwd-example .ui-block-a, .rwd-example .ui-block-c { float: left; width: 50%; } .rwd-example .ui-block-b, .rwd-example .ui-block-c { float: left; width: 25%; } } /* 3rd breakpoint - Bump up font size at very wide screens */ @media all and (min-width: 75em) { /*1200px*/ .rwd-example .ui-body { font-size: 125%; color: blue; } .rwd-example .ui-block-a, .rwd-example .ui-block-c { float: left; width: 50%; } .rwd-example .ui-block-b, .rwd-example .ui-block-c { float: left; width: 25%; } } </style> </head> <body> <!-- data-role a:黑色 b:蓝色 c:白色 d:灰色 e:黄色 --> <div data-role="page"> <div data-role="header"> <h4>grid responsive layout学习</h4></div> <div data-role="content"> <div class="rwd-example"> <!-- Lead story block --> <div class="ui-block-a"> <div class="ui-body ui-body-d"> <h2>Apple schedules 'iPad Mini' event for October 23</h2> <p>One of the worst-kept secrets in tech has been confirmed: Apple will hold an event October 23 in San Jose, California, at which the company is widely expected to unveil a smaller, cheaper version of its popular iPad called "Mini".</p> </div> </div> <!-- secondary story block #1 --> <div class="ui-block-b"> <div class="ui-body ui-body-d"> <h4>Microsoft Surface tablet goes on sale for $499</h4> <p>The Microsoft Surface tablet picture has come into focus. The Redmond giant filled in the blanks on the new tablet's availability and specs.</p> </div> </div> <!-- secondary story block #2 --> <div class="ui-block-c"> <div class="ui-body ui-body-d"> <h4>AOL unveils Alto, an email service that syncs 5 accounts</h4> <p>AOL, struggling to shed its outdated image, is reimagining one of the most visibly aging parts of its platform: Its email service. </p> </div> </div> </div><!-- /rwd-example --> </div> </div> </body> </html>
相关推荐
This updated new edition covers all the most up-to-date techniques and tools needed to build great responsive designs, ensuring that your projects won’t just be built ‘right’ for today, but in the ...
What You Will Learn Explore various layout options Understand what can be achieved in the browser, without the use of third-party tools Executing media queries to benefit responsive designs ...
Next, he delivers complete technical know-how for transforming responsive designs into responsive sites. You’ll find coverage of key issues such as integrating media content, optimizing performance,...
the second module provides a comprehensive resource for all things “responsive.” You'll explore the most up-to-date techniques and tools needed to build great responsive designs, ensuring that your...
- Techniques for creating responsive designs that adapt to different screen sizes and orientations. - Using media queries and flexible grid layouts. 12. **Case Studies and Best Practices** - Real-...
Moving to Responsive Web Design ... You will also learn to plan how your designs and patterns will adapt across various breakpoints, and how to approach the challenge of responsive images.
You will also learn to plan how your designs and patterns will adapt across various breakpoints, and how to approach the challenge of responsive images. The prospect of converting an existing site ...
Rich shares with you his skills in creating advanced layouts, and the critical CSS insights you need for responsive web designs, fonts, transitions, animations, and using flexbox. Rich begins your ...
Roll out rock solid responsive mobile first designs quickly and reliably Overview Make websites that will look great and be usable on almost any device that displays web pages Learn best practices ...
Better still, Bootstrap is built from the ground up to be fully responsive, meaning your designs will look beautiful on any device, and in any browser. Whether you're a designer or a developer, you ...
此外,"powered-designs"可能涉及到响应式设计(responsive design),这是现代网页开发的关键部分。借助媒体查询(media queries),开发者可以创建适应不同设备屏幕尺寸的布局。例如,`@media screen and (max-...
Quickly deploy innovative user experience designs to mobile devices for responsive prototyping using the exciting new features of Axure 7
CSS frameworks give front end developers the capability to create responsible or adaptive web designs that overcome the various variations of modern browsers. Bootstrap is the leading CSS framework ...
CSS frameworks give front end developers the capability to create responsible or adaptive web designs that overcome the various variations of modern browsers. Bootstrap is the leading CSS framework ...
Learn to play with Bootstrap's grid system and base CSS to ensure your designs are robust and that your development process is speedy and efficient. Then, you'll find out how you can extend your ...
Learn to play with Bootstrap's grid system and base CSS to ensure your designs are robust and that your development process is speedy and efficient. Then, you'll find out how you can extend your ...
You’ll gain his understanding of responsive web designs, web fonts, icon fonts, and the techniques used to support retina devices. Rich expands your knowledge of CSS so you can master one of the ...
自适应网页设计资源资源您可以尝试目录中的其他课程指导项目Create Improved Graphic Design Using VECTR-Part IICreating Custom Vector Graphic Design Using VECTR : Part ICreating designs using CanvaWeb page...