gpt4 book ai didi

css - 标题不会展开并列出隐藏在 View 中的元素

转载 作者:太空宇宙 更新时间:2023-11-04 06:06:16 24 4
gpt4 key购买 nike

我的测试页有 2 个问题。我试图让页眉占用页面宽度。我将宽度设置为 100%,但它仍然不会扩展到页面宽度。 “链接”项的下拉列表出现在包装元素后面,因此无法单击任何底层链接。谢谢。

代码笔:https://codepen.io/centem/pen/dBdwxw

header {
margin: 0 auto;
width: 100%
height: 40px;
}

header ul {
height: 40px;
margin: 0px;
padding: 0px;
list-style: none;
}

header ul li {
float: left;
width: 200px;
height: 40px;
background-color: black;
opacity: .75;
line-height: 40px;
text-align: center;
font-size: 20px;
color: white;
}

header ul li a {
text-decoration: none;
display: block;
}

header ul li a:hover {
background-color: green;
}

header ul li ul li {
display:none;
}

ul li:hover ul li {
display: block;
}

最佳答案

header 已设置为 100% witdth。但是,您已将固定宽度和 background 设置为 li。您可以简单地使用 flexbox 并将 flex: 1 设置为元素而不用担心它们的宽度。

body {
margin: 0 auto;
font: 1.1em;
background-image: url('CNDsplash.jpg');
background-repeat: no-repeat;
background-position: center;
}

h1,
h2,
h3,
h4,
h5 {
font-weight: 400;
}

header {
margin: 0 auto;
width: 100%;
height: 40px;
}

header ul {
height: 40px;
margin: 0px;
padding: 0px;
list-style: none;
display: flex;
}

header ul li {
height: 40px;
flex: 1;
background-color: black;
opacity: .75;
line-height: 40px;
text-align: center;
font-size: 20px;
color: white;
}

header ul li a {
text-decoration: none;
display: block;
}

header ul li a:hover {
background-color: green;
}

header ul li ul li {
display: none;
}

ul li:hover ul li {
display: block;
}

#title-heading {
float: left;
}

.hidden {
display: none;
}

.wrapper {
width: 100%;
max-width: 600px;
margin: 0 auto;
border: 2px solid #eee;
background: #fefefe;
opacity: 0.9;
filter: alpha(opacity=90);
/* for ie8 and earlier */
}

.upload-console {
/*background: #fefefe;*/
/*border: 2px solid #eee; */
padding: 20px;
/*opacity: 0.9;*/
/*filter: alpha(opacity=50);*/
/* for IE8 and earlier */
}

.upload-console-header {
padding: 0 0 20px 0;
margin: 0;
border-bottom: 2px solid #eee;
font-weight: 600;
margin-bottom: 20px;
}

.upload-console-drop {
height: 200px;
border: 2px dashed #ccc;
line-height: 200px;
color: #ccc;
text-align: center;
margin-bottom: 20px;
}

.upload-console-drop.drop {
border-color: #222;
color: #222;
}

.upload-console-body {
margin-bottom: 20px;
}

.bar {
width: 100%;
background: #eee;
padding: 3px;
border-radius: 3px;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, .2);
box-sizing: border-box;
margin-bottom: 20px;
}

.bar-fill {
height: 30px;
display: block;
background: cornflowerblue;
width: 0;
border-radius: 3px;
-webkit-transition: width 0.8s ease;
transition: width 0.8s ease;
}

.bar-fill-text {
color: #fff;
line-height: 30px;
margin-left: 5px;
}

.upload-console-upload {
border-bottom: 2px solid #ccc;
margin-bottom: 10px;
padding-bottom: 10px;
}

.upload-console-upload span {
float: right;
}
<header>
<ul>
<li><a>Home</a></li>
<li><a>Contact</a></li>
<li><a>Docs</a></li>
<li><a>Links</a>
<ul>
<li><a>Link 1</a></li>
<li><a>Link 2</a></li>
<li><a>Link 3</a></li>
</ul>
</li>
</ul>
</header>
<div class="wrapper">
<div id="form-heading">
</div>
<div class="upload-console">
<br>
<h2 class="upload-console-header">FTS</h2>

<div class="upload-console-body">
<h3>Select files</h3>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="files[]" id="standard-upload-files" multiple>
<input type="submit" value="Upload files" id="standard-upload">
</form>

<h3>Or drag and drop files below</h3>
<div class="upload-console-drop" id="drop-zone">
Just drag and drop files here
</div>

<div class="bar">
<div class="bar-fill" id="bar-fill">
<div class="bar-fill-text" id="bar-fill-text"></div>
</div>
</div>

<div id="uploads-finished" class="hidden">
<h3>Processed Files</h3>
</div>

</div>

</div>
</div>

关于css - 标题不会展开并列出隐藏在 View 中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56830560/

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