html 不会为小屏幕加载 css

标签 html css media

我有一个问题,html 不会为小屏幕加载 css。 我已经使其他 css 加载没有问题。那些有效的有背景图像,但一个用于宽度小于 500 像素的小屏幕却没有。它只有背景颜色。我试图将图像缩放到 500px 并在 small.css 中添加为背景图像并且它有效但我不会这样做。 请帮忙。 这是 html 代码:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-        scale=1.0, initial-scale=1.0" />
<title>PROCYCLING   |   MTB klub</title>
<link rel="stylesheet" type="text/css" href="mainstyle.css" />
<link rel="stylesheet" type="text/css" media="only screen and (min-width:801px) and   (max-width:1024px)" href="large.css" />
<link rel="stylesheet" type="text/css" media="only screen and (min-width:501px) and (max-width:800px)" href="medium.css" />
 <link rel="stylesheet" type="text/css" media="only screen and (min-width: 50px) and (max-width:500px)" href="small.css" />
 <!--[if lt IE 9]>
 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 <![endif]-->
</head>
<body>
</body>

这是没有背景图片的 CSS:

@charset "UTF-8";
/* Small Content Formatting */
body{
  color:#6fe123;
  line-height:1.5em;
  font-family: Myriad Pro, Arial, Verdana;
  font-size: 14px;
  background-color: #2a2a2a;
 }

最佳答案

我倒过来理解这个问题。我认为它没有在应该显示图像的时候显示图像。 问题是它显示是因为另一个 CSS 文件,它不应该显示。

在这种情况下,最好明确告诉 CSS 不要使用背景图片:

背景图像:无;

关于html 不会为小屏幕加载 css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17133258/

相关文章:

javascript - 在 ng-repeat 内部时,移动 Angular UI 选项卡样式未应用

javascript - 如何使右箭头可点击,它应该模拟按下回车键

css - 媒体查询中的评论

css - 最佳方法和覆盖 bootstrap css 时遇到问题

javascript - 由于重复请求,视频元素无法加载

html - 将过滤器应用于部分背景图像

php - PHP 中的骰子滚动程序

css - 为什么 IE 在渲染空 SVG 元素时卡住布局?

html - 如何创建固定屏幕布局

javascript - 根据随机数组结果播放特定的声音?