二、关键字
and - 结合多个媒体查询 not - 排除某种制定的媒体类型 only - 用来定某种特定的媒体类型
三、引用样式示例
- <link rel="stylesheet" media="all" href="style.css" />
- <link rel="stylesheet" media="screen and (min-width:980px)" href="desktop.css" />
- <link rel="stylesheet" media="screen and (min-width:768px) and (max-width:980px)" href="pad.css" />
- <link rel="stylesheet" media="screen and (min-width:480) and (max-width: 768px)" href="phone.css" />
- <link rel="stylesheet" media="screen and (max-width:320px)" href="small.css" />
四、内联样式示例
- @media screen and (min-width: 980px) {
- //css code
- }
- @screen and (min-width:768px) and (max-width:980px) {
- //css code
- }
- @screen and (min-width:480) and (max-width: 768px) {
- //css code
- }
- @screen and (max-width:320px) {
- //css code
- }
- @media screen and (max-device-width: 480px) {
- //max-device-width等于480px
- }
- @media screen and (device-aspect-ratio: 16/9), screen and (device-aspect-ratio: 16/10) {
- //设备宽高比
- }
- @media all and (orientation:portrait) {
- //竖屏
- }
- @media all and (orientation:landscape) {
- //横屏
- }
五、I8的兼容性问题解决
问题根源:
在项目的CSS文件中采用了media这东东来根据视窗的大小自动调整布局,但是,但是IE8及以下版本浏览器不支持CSS3 media queries,也就是@media screen and (max-width: 900px) 里面的css代码没有执行,
- @media screen and (max-width: 900px) {
- ...
- }
这如何是好啊,网上倒是有不少人提出解决方法,最简单的方法就是:
IE8和之前的浏览器不支持CSS3 media queries,你可以在页面中添加css3-mediaqueries.js来解决这个问题。
- <!--[if lt IE 9]>
- <script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script>
- <![endif]-->
原来如此,还挺简单嘛,结果大失所望啊,项目中怎么试怎么就不行呢,还望试过可行的同仁点拨点拨啊,没办法只能采用另一种稍微复杂些的方法,也是从网上学来,这里要考虑两个问题,一是只有IE8及其低版本才做此处理,二是只有浏览器缩小到某一个大小范围后才做此处理。方法如下:
原理:采用jquery,其实不懂,会用就行,然后在html中根据需要来改变对应的CSS文件
解决方法:
在所有页面的共用js文件后面添加如下代码:
- /*Adjust the layout in IE8 and lower than IE8 when the browser is narrow*/
- function processLowerIENavigate()
- {
- var isIE = document.all ? 1 : 0;
- if (isIE == 1)
- {
- if(navigator.userAgent.indexOf("MSIE7.0") > 0 || navigator.userAgent.indexOf("MSIE 8.0") > 0)
- {
- // var doc=document;
- var link=document.createElement("link");
- link.setAttribute("rel", "stylesheet");
- link.setAttribute("type", "text/css");
- link.setAttribute("id", "size-stylesheet");
- link.setAttribute("href", "");
- var heads = document.getElementsByTagName("head");
- if(heads.length)
- heads[0].appendChild(link);
- else
- document.documentElement.appendChild(link);
- document.write("<script type='text/javascript' src='jquery.min.js'></script>");
- document.write("<script type='text/javascript' src='media_screen.js'></script>");
- }
- }
- }
- var lowerIE8 = processLowerIENavigate();
- media_screen.js文件内容如下,直接从网上copy:
- function adjustStyle(width) {
- width = parseInt(width);
- if (width < 902) {
- //alert("<900");
- //alert(width);
- $("#size-stylesheet").attr("href", "navigateLowerIE8.css");
- } else {
- // alert(">900");
- //alert(width);
- $("#size-stylesheet").attr("href", "");
- }
- }
- $(function() {
- adjustStyle($(this).width());
- $(window).resize(function() {
- adjustStyle($(this).width());
- });
- });
navigateLowerIE8.css文件就是IE8其低版本浏览器在缩小时的页面布局了。OK,一切都确实搞定。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 群星《前途海量 电影原声专辑》[FLAC/分轨][227.78MB]
- 张信哲.1992-知道新曲与精丫巨石】【WAV+CUE】
- 王翠玲.1995-ANGEL【新艺宝】【WAV+CUE】
- 景冈山.1996-我的眼里只有你【大地唱片】【WAV+CUE】
- 群星《八戒 电影原声带》[320K/MP3][188.97MB]
- 群星《我的阿勒泰 影视原声带》[320K/MP3][139.47MB]
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[320K/MP3][148.91MB]
- 刘雅丽.2001-丽花皇后·EMI精选王【EMI百代】【FLAC分轨】
- 齐秦.1994-黄金十年1981-1990CHINA.TOUR.LIVE精丫上华】【WAV+CUE】
- 群星.2008-本色·百代音乐人创作专辑【EMI百代】【WAV+CUE】
- 群星.2001-同步过冬AVCD【环球】【WAV+CUE】
- 群星.2020-同步过冬2020冀待晴空【环球】【WAV+CUE】
- 沈雁.1986-四季(2012梦田复刻版)【白云唱片】【WAV+CUE】
- 纪钧瀚《胎教古典音乐 钢琴与大提琴的沉浸时光》[FLAC/分轨][257.88MB]
- 《国语老歌 怀旧篇 3CD》[WAV/分轨][1.6GB]