gpt4 book ai didi

html - 如何使 Logo 居中并使导航右对齐,然后堆叠在顶部以实现响应

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

我在获得结果时遇到问题,方法是让 Logo 居中,然后将导航右对齐并在标题内垂直居中,然后当它缩小到响应模式时,它将相互堆叠。我可以通过使导航position:absolute;在桌面模式下获得所需的效果;但随后它搞砸了我的响应查询。

有人有想法吗?

这是 fiddle :http://jsfiddle.net/W37Wq/1/

HTML

<div class="header">
<div class="header-inner">
<a href="www.google.com"><img class="logo" src="http://www.techcityng.com/wp-content/uploads/2013/07/google.jpg"></a>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Let's Partner</a>
<a href="#">Contact</a>
</nav>
</div>
</div>

<header class="clearfix">

CSS

.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #f6f6f6;
z-index: 10000;
height: 100px;
overflow: hidden;
}

.header .header-inner {
width: 90%;
max-width: 69em;
margin: 0 auto;
padding: 0 1.875em;
text-align: center;
}

.header h1,
.header nav a {
line-height: 100px;
}

.header h1 {
text-transform: uppercase;
color: #333;
letter-spacing: 4px;
font-size: 1em;
display: block;
block;
margin: 0 auto;
text-align: center;
float: none;
overflow: hidden;
}

.header nav {
display: inline-block;
text-align: right;
list-style: none;
margin-left: 5em;
position: absolute;
}

.header nav a {
color: #aaa;
font-weight: 700;
margin: 0 0 0 20px;
font-size: .9em;
}

.header nav a:hover {
color: #333;
}

.logo {
display: inline-block;
max-width: 198px;
max-height: 100px;
}

@media screen and (max-width: 55em) {

.header .header-inner {
width: 100%;
}

.header .logo,
.header nav {
display: block;
margin: 0 auto;
text-align: center;
float: none;
}

.header .logo,
.header nav a {
line-height: 50px;
}

.header nav a {
margin: 0 10px;
}

.header .logo,
.header.header-shrink nav a {
line-height: 45px;
}

.header .logo {
font-size: 2em;
max-height: 60px;


}

.header.header-shrink nav a {
font-size: 1em;
}
}

@media screen and (max-width: 32.25em) {
.header nav a {
font-size: .9em;
}
}

@media screen and (max-width: 24em) {
.header nav a,
.header.header-shrink nav a {
line-height: 1;
}
}

http://jsfiddle.net/W37Wq/1/

谢谢!

最佳答案

http://jsfiddle.net/W37Wq/4/

承格这个类:

    .header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #f6f6f6;
z-index: 10000;
height: 110px;
overflow: hidden;
}

.header .header-inner {
width: 90%;
margin: 0 auto;
padding: 0% 5%;
text-align: center;
}

@media screen and (max-width: 55em) {

.header .header-inner {

}

.header .logo,
.header nav {
display: block;
margin: 0 auto;
text-align: center;
float: none;
width:90%;
}
}

关于html - 如何使 Logo 居中并使导航右对齐,然后堆叠在顶部以实现响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18028900/

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