gpt4 book ai didi

html - 缩放时根据导航栏调整文本+图像的大小

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

当我缩放我的网站时, Logo 和文本往往不会按照与 div 本身相同的比例调整大小。 div 在 css 中设置了 % 以始终显示为相同的大小。缩放时如何使它们调整大小相等?

我试过在 % 中设置字体大小,但这不起作用。该图像已经是完美的尺寸,所以我没有在 css 中调整它的大小。

Live example on the jsFiddle

HTML:

<div id=nav>
<div id="logo">
<img src="50.png">
</div>
<div id="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Music</a></li>
<li><a href="#">Spotlight</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">What is ?</a></li>
</ul>
</div>
</div>

CSS:

#logo{
position: absolute;
left: 10px;
top: -2px;
}
#nav{
height: 7%;
background-color: #fbfbfb;
list-style-type: none;
position: fixed;
z-index: 100;
top: 0px;
width: 100%;
left: 0%;
border-bottom: 1px solid;
border-color: #02ddfe;
}
#menu{
width: 960px;
margin: 0 auto;
text-align: left;
position: fixed;
left: 2%;
font-size: 100%;
top: -2%;
}
#menu ul{
list-style-type: none;
text-align: center;
vertical-align: middle;
line-height: 47px;
position: absolute;
}
#menu ul ul{
display: none;
}
#menu ul a{
color: #bbbbbb;
text-decoration: none;
-webkit-transition: color 0.4s;
-moz-transition: color 0.4s;
transition: color 0.4s;
}
#menu ul li{
display: inline-block;
text-align: center;
}
#menu ul li a,visited{
color: #bbbbbb;
display: block;
padding: 0px;
padding-left: 20px;
text-decoration: none;
}
#menu ul li a:hover{
color: #4ebbe8;
text-decoration: none;
}
#menu ul li:hover ul{
display: block;
}
#menu ul ul{
background-color: #ffffff;
position: absolute;
display: none;
margin: 0px;
padding: 0px;
}

最佳答案

试试这个:http://jsfiddle.net/rfv2h3m5/1/

代码更改:HTML:

<div id="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Music</a></li>
<li><a href="#">Spotlight</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">What is ?</a></li>
</ul>
</div>

CSS:

#logo{
position: absolute;
left: 10px;
top: 10px;
background:url("http://www.fnordware.com/superpng/pnggrad8rgb.png") no-repeat;
width:8%;
height:72%;
background-size: 100%;
}
#nav{
height: 40%;
background-color: #fbfbfb;
list-style-type: none;
position: fixed;
z-index: 100;
top: 0px;
width: 100%;
left: 0%;
border-bottom: 1px solid;
border-color: #02ddfe;
font-size : 100%;
}
#menu{
width: 90%;
margin: 0 auto;
text-align: left;
position: fixed;
left: 2%;
font-size: 100%;
top: -2%;
}
#menu ul{
list-style-type: none;
text-align: center;
vertical-align: middle;

}
#menu ul ul{
display: none;
}
#menu ul a{
color: #bbbbbb;
text-decoration: none;
-webkit-transition: color 0.4s;
-moz-transition: color 0.4s;
transition: color 0.4s;
}
#menu ul li{
display: inline-block;
text-align: center;
}

#menu ul li a,visited{
color: #bbbbbb;
display: block;
padding: 0px;
padding-left: 20px;
text-decoration: none;
}
#menu ul li a:hover{
color: #4ebbe8;
text-decoration: none;
}
#menu ul li:hover ul{
display: block;
}
#menu ul ul{
background-color: #ffffff;
position: absolute;
display: none;
margin: 0px;
padding: 0px;
}

关于html - 缩放时根据导航栏调整文本+图像的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28339603/

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