我正在做一个项目,在那里我使用媒体查询来响应设计。
我总共有4个媒体查询。
在计算机上,当我调整浏览器的大小时,我使用所有的媒体查询,它工作得很好。
在智能手机上,我不明白为什么,我没有任何css。
即使我在我的样式表之外的媒体查询*{display: none;},在我的智能手机内容出现。
你知道为什么会发生这种事吗?
我有一个index.php文件,用来导入css和js,还有一个函数HomePage(),它调用我的主页。
?php
ob_start(); session_start();
require_once('code/db.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="device-width, initial-scale=1, maximum-scale=1" />
<title>Untitled Document</title>
<link rel="icon" type="image/png" href="<?php setHome();?>/template/images/icon.png" />
<link href="<?php setHome();?>/template/css/styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="<?php setHome();?>/template/fonts/fonts.css" />
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="<?php setHome();?>/template/acc/css/jquery-ui-style.css" type="text/css" />
<script type="text/javascript" src="<?php setHome();?>/template/js/jquery.js"></script>
<script type="text/javascript" src="<?php setHome();?>/template/js/scripts.js"></script>
<?php
HomePage();
?>我的setHome函数:
function setHome(){
echo 'http://localhost/website';
}如果我像这样导入我的css,它会工作:
<link href="template/css/styles.css" rel="stylesheet" type="text/css" />但像这样不管用:(但在计算机上工作)
<link href="http://localhost/website/template/css/styles.css" rel="stylesheet" type="text/css" />像这样也不起作用:(但在计算机上工作)
<link href="<?php setHome();?>/template/css/styles.css" rel="stylesheet" type="text/css" />发布于 2014-07-10 19:37:41
如果这是你的实际代码,答案很简单
http://localhost会在你的电脑上工作,但当你从手机上访问它时,它会尝试连接到localhost,即手机,而不是电脑--你需要把你的实际主机名或IP地址放在那里。
https://stackoverflow.com/questions/24665746
复制相似问题