gpt4 book ai didi

html - 我在响应式菜单中遇到问题

转载 作者:行者123 更新时间:2023-11-28 08:34:35 25 4
gpt4 key购买 nike

我在响应式菜单中遇到问题。如果您缩小浏览器并单击菜单图像。它不会按顺序显示。检查此链接。 http://vkacademy.in/res/我需要使用的属性是什么。在 mobile.css 文件中,我使用了 common 类。我想知道我需要在 common 类中使用额外的属性来正确显示菜单。我知道只能使用像素。请以像素为单位给我答案。

<script src="js/jquery-1.7.2.min.js"></script>
<script>
$(document).ready(function(e) {
$('#mob_btn').click(function(e) {
$('.common').slideToggle(1000);
});
});
</script>

<body>
<div id="wrapper">
<div id="logo"><img src="image/logo.png" border="0" width="357" height="107"/></div><!--endoflogo-->
<div id="logo1"><a href="#">join as tutor or Institutue</a></div><!--endoflogo1-->
<div class="menu_btn"><img id="mob_btn" src="image/menu.png"/></div>
<div id="menu">
<div class="common"><a href="#">About us</a></div>
<div class="common"><a href="#">Department</a></div>
<div class="common"><a href="#">Facilities</a></div>
<div class="common"><a href="#">library</a></div>
<div class="common"><a href="#">Event</a></div>
</div><!--endofmenu-->
</div><!--endofwrapper-->
my default.css
body
{
margin:auto;
background-color:#CCCCCC;
background-repeat:repeat;
}
#wrapper
{
width:1000px;
height:auto;
margin:auto;
}

#logo
{
width:500px;
height:100px;
float:left;
}
#logo1
{
width:400px;
height:80px;
float:left;
padding-left:50px;
padding-right:50px;
background-color:#FF00FF;
}

#menu
{
width:1000px;
height:45px;
float:left;
}

.common
{
width:200px;
height:42px;
padding-top:8px;
float:left;
background-color:#FFFFFF;
background-repeat:no-repeat;
text-align:center;
}

#content
{
width:1000px;
height:auto;
float:left;
}
.menu_btn
{
display: none;
}

**In mobile.css**
@media only screen and (max-width:530px)
{
#wrapper
{
width:260px;
background-repeat:repeat;

}

#logo
{
width:260px;
text-align:center;
background-color:#FFFF00;
}

#logo img
{
width:260px;
text-align:center;
}

#logo1
{
width:160px;
padding-left:50px;
padding-right:50px;
height:auto;
}

.menu_btn
{
width:260px;
height:48px;
display:block;
text-align:right;
border-bottom:1px solid #CCCCCC;
}

.common
{
width:260px;
display:none;

}

.common
{
width:260px;
border-bottom:1px solid #CCCCCC;
}
}

最佳答案

如@jorge9200 所述,您需要先了解媒体查询。 Here is a link for easier understanding .

一个基本的/更快的例子:

/* Mobile first queries */

/* Larger than mobile */
@media (min-width: 400px) { your own CSS for this particular screen size }

/* Larger than phablet */
@media (min-width: 550px) {your own CSS for this particular screen size}

/* Larger than tablet */
@media (min-width: 750px) {your own CSS for this particular screen size}

/* Larger than desktop */
@media (min-width: 1000px) {your own CSS for this particular screen size}

/* Larger than Desktop HD */
@media (min-width: 1200px) {your own CSS for this particular screen size}

上述媒体查询是为主要屏幕尺寸预定义的。您可以使用它们并为每个类和 ID 编写 CSS或者你可以使用像 Twitter Bootstrap 这样的响应式 CSS 框架为了更快的发展。

关于html - 我在响应式菜单中遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28109418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com