gpt4 book ai didi

css - RWD 移动优先导航 CSS

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

我在从头开始制作自定义纯 css 移动优先响应导航时遇到了问题。我有这个在互联网上找到的导航菜单,并试图操纵代码,这样我就可以在内联 block 上有一个水平导航栏。当我将媒体查询设置为最小宽度:480px 并隐藏导航图标时,我希望导航栏像桌面版本一样取消折叠并显示链接。不知道到底该怎么做。这是我到目前为止所拥有的。任何帮助将不胜感激谢谢。这是我试图修改的未经编辑的原始导航条码

演示:http://cssdeck.com/labs/dropdown-menu

HTML:

 <body>
<div id="header">
<div id="logo">
</div>

<input type="checkbox" class="checkbox" name="menu" value="mobiledropmenu" id="mobiledropmenu">
<label for="mobiledropmenu" class="label"><img src="http://developer.jmbarcelon.com/Images/dropmenu.png"></label>

<div class="title">
<div class="button">Home</div>
<div class="button">Casa</div>
<div class="button">Zahause</div>
<div class="button">Maison</div>
</div>


<h1>Drop-Down Menu</h1>

</div>

CSS:

background:#E5F2FF;
}

#header {
width:100%;
background:#72BBFF;
z-index:2;
}

.checkbox {
display: none;
}
.label{
-webkit-transition:.3s;
-moz-transition:.3s;
-o-transition:.3s;
transition:.3s;
width: 64px;
height:64px;
font-size: 20px;
display: inline-block;
background-size:cover;
margin:.5em;
background:rgba(0,132,255,0.15);
box-shadow: 1px 1px 5px rgba(0, 135, 255,0.5);
border-radius:1px;
}

.checkbox:checked + .label {
-webkit-transition:.3s;
-moz-transition:.3s;
-o-transition:.3s;
transition:.3s;
box-shadow:inset 0px 0px 10px rgba(0, 135, 255,0.5);
background:rgba(0,132,255,0.3)
}

#mobiledropmenu:checked ~ .title {
-webkit-transition:1s;
width: 100%;
height: 250px;
opacity: 1;
}

.title {
-webkit-transition:1s;
width: 0%;
height: 0px;
opacity: 0;
}

.button {
color:#fff;
text-decoration:none;
border-top:1px solid #fff;
text-align:center;
text-transform:uppercase;
width:100%;
padding:1.2em;
}

.button:hover {
cursor:pointer;
background:rgba(0,132,255,0.15);
}


h1 {
width:100%;
color:rgba(188, 230, 255, 0.2);
text-align:center;
text-transform:uppercase;
text-shadow: 1px 3px 6px #E5F2FF,
0 0 0 #47a0d3,
1px 4px 6px #E5F2FF;
font-weight:lighter;
font-size:2.5em;
position:absolute;
margin-top:10%;
}

@media only screen and (min-width: 480px){
h1{color: red;}
.label {display: none;}
.title {display: inline-block;

最佳答案

好的,我删除了错误的开始,这是一个基于您编辑的问题的工作示例。我在您的链接代码的 CSS 下添加了这个:

@media only screen and (min-width: 480px){
/* always show the nav, and make it a fixed height */
.title {
width: 100%;
height: 50px;
opacity: 1;
}

/* change nav items to be horizontal and only as big as they need */
.button {
height: 50px;
display: inline-block;
width: auto;
}
/* hide the menu toggle button */
.label { display: none; }
}

这样做是隐藏菜单切换并将导航切换为始终可见且水平。示例在这里:http://cssdeck.com/labs/hehuga5u (调整右侧 Pane 的大小以查看其运行情况)

同样,您必须进行调整才能满足您的确切需求,但这应该更接近您的需求。祝你好运!

关于css - RWD 移动优先导航 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20865611/

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