我想做一个固定标题,左边是可单击的链接,右边是我们的徽标。
将文本+图像浮动到相应位置并使标题占据屏幕的整个宽度没有问题。一旦“固定”,标题的宽度就会缩小到我添加的3个链接的宽度。
标题的宽度已经设置为100%,我似乎找不到根本的问题
html {
scroll-behavior: smooth;
}
.clear {
clear: both;
}
header {
width 100%;
height: 100px;
position: fixed;
color: rgb(255, 0, 0);
top: 0;
left: 0;
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1);
z-index: 999;
}
footer {
height: 30px;
color: black;
text-align: center;
box-shadow: 1px 0 4px 0 rgba(0, 0, 0, 0.1);
}
header ul {
list-style: none;
float: left;
text-transform: uppercase;
font-family: 'Source Sans Pro';
font-weight: bold;
}
header ul li {
float: left;
margin-left: 60px;
line-height: 100px;
}
header ul a {
text-decoration: none;
}
header ul a:hover {
color: rgb(200, 0, 0);
}
.thumb-container {
max-width: calc(960px + 40px);
margin: 110px auto 0 auto;
}
.thumb-container a {
width: calc(960px / 3);
height: calc(960px / 3);
background: aqua;
float: left;
margin: 0 5px 10px 5px;
}
@media screen and (max-width: 1000px) {
.thumb-container {
max-width: 660px;
/* in midden zetten */
background: black;
}
}
@media screen and (max-width: 660px) {
.thumb-container {
max-width: 100%;
/* in midden zetten */
background: black;
}
.thumb-container a {
width: 100%;
/* maakt containers volledige breedte*/
margin: 0 0 10px 0;
}
}
<header>
<nav>
<ul>
<li> <a href="index.html"> Home </a></li>
<li> <a href="#"> Benodigdheden </a></li>
<li> <a href="#"> Over ons </a></li>
</ul>
</nav>
<img src="img/" alt="lol">
</header>
<main>
<div class="thumb-container">
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<div class="clear"></div>
</div>
</main>
<footer> Test footer text</footer>
答案 0 :(得分:1)
尝试一下
body {margin:0;}
.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}
.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.navbar a:hover {
background: #ddd;
color: black;
}
.main {
padding: 16px;
margin-top: 30px;
height: 1500px;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="navbar">
<a href="#home">Home</a>
<a href="#news">Benodigdheden</a>
<a href="#contact">Contact</a>
</div>
<div class="main">
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
</div>
</body>
</html>
答案 1 :(得分:0)
设置宽度时,您缺少“:”!
应该为delegate.taskWillPerformHTTPRedirectionWithCompletion = { session, task, response, request, completion in
if(needLoginLogic){
login_bg(){ (result) in
switch result {
case .success:
// Make the original request inteast of "/login" request
completion(task.originalRequest)
break
case .failure(let error):
// Catch error later.
completion(request)
break
}
}
}else{
// Just make the request
completion(request)
}
}
而不是width: 100%;
width 100%;
html {
scroll-behavior: smooth;
}
.clear {
clear: both;
}
header {
width: 100%;
height: 100px;
position: fixed;
color: rgb(255, 0, 0);
top: 0;
left: 0;
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1);
z-index: 999;
}
footer {
height: 30px;
color: black;
text-align: center;
box-shadow: 1px 0 4px 0 rgba(0, 0, 0, 0.1);
}
header ul {
list-style: none;
float: left;
text-transform: uppercase;
font-family: 'Source Sans Pro';
font-weight: bold;
}
header ul li {
float: left;
margin-left: 60px;
line-height: 100px;
}
header ul a {
text-decoration: none;
}
header ul a:hover {
color: rgb(200, 0, 0);
}
.thumb-container {
max-width: calc(960px + 40px);
margin: 110px auto 0 auto;
}
.thumb-container a {
width: calc(960px / 3);
height: calc(960px / 3);
background: aqua;
float: left;
margin: 0 5px 10px 5px;
}
@media screen and (max-width: 1000px) {
.thumb-container {
max-width: 660px;
/* in midden zetten */
background: black;
}
}
@media screen and (max-width: 660px) {
.thumb-container {
max-width: 100%;
/* in midden zetten */
background: black;
}
.thumb-container a {
width: 100%;
/* maakt containers volledige breedte*/
margin: 0 0 10px 0;
}
}
答案 2 :(得分:0)
您可以通过设置属性right: 0;
来解决此问题。如果看我的示例,我建议您删除float: left;
并改用display: flex;
。我更改了您的示例以反映我的意思。希望这会有所帮助。
我建议您看一下这篇文章和视频
html {
scroll-behavior: smooth;
}
* {
box-sizing: border-box;
}
.header {
position: fixed;
top: 0;
right: 0;
left: 0;
display: flex;
align-items: center;
height: 100px;
color: rgb(255, 0, 0);
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1);
z-index: 2;
background-color: deepskyblue;
}
.header__logo {
width: 4rem;
height: 2rem;
margin-left: auto;
background-color: aqua;
}
.navigation-links {
display: flex;
list-style: none;
text-transform: uppercase;
font-family: 'Source Sans Pro';
font-weight: bold;
}
.navigation-links__link {
margin-left: 60px;
line-height: 100px;
}
.navigation-links__link a {
display: block;
text-decoration: none;
}
.navigation-links__link a:hover {
color: rgb(200, 0, 0);
}
footer {
height: 30px;
color: black;
text-align: center;
box-shadow: 1px 0 4px 0 rgba(0, 0, 0, 0.1);
}
.thumb-container {
display: flex;
flex-wrap: wrap;
max-width: calc(960px + 40px);
margin: 110px auto 0 auto;
}
.thumb-container a {
width: calc(960px / 3);
height: calc(960px / 3);
background: aqua;
margin: 0 5px 10px 5px;
}
@media screen and (max-width: 1000px) {
.thumb-container {
max-width: 660px;
/* in midden zetten */
background: black;
}
}
@media screen and (max-width: 660px) {
.thumb-container {
max-width: 100%;
/* in midden zetten */
background: black;
}
.thumb-container a {
width: 100%;
/* maakt containers volledige breedte*/
margin: 0 0 10px 0;
}
}
<header class="header">
<nav class="navigation">
<ul class="navigation-links">
<li class="navigation-links__link"> <a href="index.html"> Home </a></li>
<li class="navigation-links__link"> <a href="#"> Benodigdheden </a></li>
<li class="navigation-links__link"> <a href="#"> Over ons </a></li>
</ul>
</nav>
<!--<img src="img/" alt="lol" class="header__logo">-->
<div class="header__logo"></div>
</header>
<main>
<div class="thumb-container">
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
</div>
</main>
<footer> Test footer text</footer>
答案 3 :(得分:0)
您错过了width属性的“:”。 请更正。