标题部分的导航链接部分是下拉列表,但在桌面网站中,它是全宽导航,并且Carousel位于移动版本的页面底部,在桌面版本的页面顶部显示。如何我可以为桌面和移动版本的网站提供不同的布局吗?请帮忙!
答案 0 :(得分:2)
您的描述并不是很好,但我认为您希望在移动设备上使用最小化的菜单,而在台式机/笔记本电脑上使用完整版本。您无法单独使用HTML5进行更改,必须使用媒体查询。
以下是我使用的一些示例,将这些示例放在底部pref中包含的CSS文件中:
/* All Mobile Sizes (devices and browser) */
@media only screen and (max-width: 767px) {}
/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
@media only screen and (min-width: 480px) and (max-width: 767px) {
/*Insert your tablet CSS in here!
}
/* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
@media only screen and (max-width: 479px) {
/*Insert your mobile CSS in here!
}
希望这有帮助, 中号
答案 1 :(得分:1)
您可以使用bootstrap。它具有全局CSS设置。这是一种非常简单的方法see the docs
通过重新调整浏览器大小来查看此示例。
<!DOCTYPE HTML>
<html>
<head>
<title> Bootstrap navbar</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
</head>
<body style="margin-bottom:80px;">
<div class = "navbar navbar-inverse navbar-static-top">
<div class="container">
<a href = "#" class = "navbar-brand">Murali Krishna</a>
<button class = "navbar-toggle" data-toggle = "collapse" data-target = ".navHeaderCollapse">
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
<span class = "icon-bar"></span>
</button>
<div class = "collapse navbar-collapse navHeaderCollapse">
<ul class = "nav navbar-nav navbar-right">
<li><a href = "bootstrap.html">Home</a></li>
<li class="active"><a href = "#">Blog</a></li>
<li class="dropdown">
<a href="#" class = "dropdown-toggle" data-toggle="dropdown">Social Media<span class = "caret"></span></a>
<ul class = "dropdown-menu">
<li><a href = "#">Facebook</a></li>
<li><a href = "#">Twitter</a></li>
<li><a href = "#">Google+</a></li>
</ul>
</li>
<li><a href = "#">About</a></li>
<li><a href = "#contact" data-toggle="modal">Contact</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>