- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我是 HTML/CSS/Javascript 的新手,我正在努力减小我网页上 slider 轮播中背景图片的大小。我想做的是减小背景图片的大小,使其位于我的登录名上方而不是下方,然后在我的登录名后面有一个黑色背景。
请看我的网页图片> https://imgur.com/NcqqZk1
html body
{
margin:0;
padding:0;
}
body{
height:100%;
background-color:black !important;
}
/*-------------header-----------*/
header
{
height:110px;
line-height: 110px;
position:fixed;
z-index:1;
width:100%;
}
.secondary{
background-color:darkorange;
box-shadow:0px 0px 15px 0px;
transition:all 0.5s ease-in-out;
}
/*-------------nav-----------*/
ul
{
list-style:none;
}
ul li
{
display:inline-block;
}
header nav
{
float: right;
}
.logo img
{
margin-top:-20px;
height:30px;
}
header nav ul li a
{
padding-right: 25px;
font-weight: bold;
color: white;
transition: all 0.5s ease-in;
}
header nav ul li a:hover
{
text-decoration: none;
color:black;
}
/*-------------slider-----------*/
.img1
{
background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work.jpg);
background-size:100% 100%;
}
.slider,.slider ul,.slider ul li
{
height:100%;
width:100%;
color:white;
text-align: center;
padding:0px;
}
.slider h2
{
font-weight: bold;
margin-top:260px;
}
.slider span
{
color:orange;
}
.slider a
{
padding: 10px 40px;
margin-right: 10px;
}
/*-------------slider-button-----------*/
.slider a.btn-half
{
background-color: orange;
color: white;
width:200px;
}
.slider a.btn-half:hover
{
opacity:0.7;
transition:0.5s ease-in;
}
.img2
{
background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work2.jpg);
background-size:100% 100%;
}
.img3
{
background-image:linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.7)),url(work3.jpg);
background-size:100% 100%;
}
.slider i
{
font-size:30px;
margin-right:10px;
}
/*-------------login-----------*/
.login-box
{
width:280px;
position:absolute;
top:1000px;
left:50%;
transform: translate(-50%, -50%);
color:white;
}
.login-box h1
{
width:100px;
font-size:40px;
border-bottom: 6px solid darkorange;
margin-bottom:50px;
padding:13 px 0;
}
.textbox
{
width:100%;
overflow:hidden;
font-size:20px;
padding:8px 0;
margin:8px 0;
border-bottom: 1px solid darkorange;
}
.textbox i
{
width:26px;
float:left;
text-align:center;
}
.textbox input
{
border:none;
outline:none;
background:none;
color:white;
font-size:17px;
width:80%;
float:left;
margin:0 10px;
}
.btn
{
width:100%;
background:none;
border:2px solid darkorange;
color:white;
padding:5px;
font-size:17px;
cursor:pointer;
margin:12px 0;
}
.btn:hover
{
opacity:0.7;
transition:0.5s ease-in;
}
/*-------------FAQ-----------*/
.fqcontainer
{
max-width: 60%;
margin:0 auto;
padding:70px 0 20px;
width:100%;
}
.fqcontainer h1
{
text-align: center;
font-family: 'roboto', 'sans-serif';
font-size: 60px;
margin:50px 0 0;
color: white;
}
.acc
{
border-bottom:1px solid white;
}
.acc h3
{
font-size:25px;
background-color: black rgba(0,0,0,0.6);
color: white;
padding:15px;
margin:0;
cursor:pointer;
font-family:'roboto','sans-serif';
letter-spacing: 2px;
position:relative;
}
.acc h3:after
{
content: '+';
position:absolute;
right: 20px;
font-size:40px;
top:50%;
transform:translateY(-50%);
}
.acc.active h3:after
{
content:'-';
}
.fqcontent
{
background-color:white;
margin-top:0;
line-height:1.5;
display:none;
}
.content-inner
{
padding:15px;
}
/*-------------footer-----------*/
.footer {
width:100%;
background-color: darkorange;
padding:50px 0px;
}
footer nav
{
text-align:center;
}
footer nav ul li a
{
padding-right: 25px;
font-weight: bold;
color: white;
transition: all 0.5s ease-in;
}
footer nav ul li a:hover
{
text-decoration: none;
color:black;
}
<html>
<body>
<!-------------Header/Nav----------->
<header>
<div class="container">
<div class="row">
<a href="index.html" class="logo"><img src="logo.png"></a>
<nav>
<ul>
<li><a href="#login-box">Log In</a></li>
<li><a href="">FAQ</a></li>
<li><a href="">My Surveys</a></li>
</ul>
</nav>
</div>
</div>
</header>
<!-------------Slider----------->
<section class="slider">
<ul class="slider-carousel" id="slider-carousel">
<li class="img1">
<h2>Slider<span>Slider</span></h2>
<p>Hello World</p>
<i class="fab fa-apple"></i>
<i class="fab fa-android"></i>
<i class="fab fa-windows"></i>
<p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
</p><br>
<a href="" class="btn btn-half">Get Started</a>
</li>
<li class="img2">
<h2>Slider<span>Slider</span></h2>
<p>Hello World</p>
<i class="fab fa-apple"></i>
<i class="fab fa-android"></i>
<i class="fab fa-windows"></i>
<p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
</p><br>
<a href="" class="btn btn-half">Get Started</a>
</li>
<li class="img3">
<h2>Slider<span>Slider</span></h2>
<p>Hello World</p>
<i class="fab fa-apple"></i>
<i class="fab fa-android"></i>
<i class="fab fa-windows"></i>
<p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
</p><br>
<a href="" class="btn btn-half">Get Started</a>
</li>
</ul>
</section>
<!-------------Login----------->
<div class="login-box">
<div id="login-box">
<h1>Login</h1>
<div class="textbox">
<i class="fas fa-user"></i>
<input type="text" placeholder="Username" name="" value="">
</div>
<div class="textbox">
<i class="fas fa-lock"></i>
<input type="text" placeholder="Password" name="" value="">
</div>
<input class="btn" type="button" name="" value="Sign In">
</div>
</div>
<!-------------FAQ----------->
<div class="fqcontainer">
<h1>FAQ Section</h1>
<div class="acc">
<h3>Question 1: What is?</h3>
<div class="fqcontent">
<div class="content-inner">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien turpis, tincidunt nec maximus et, elementum vel massa. Sed quis suscipit tortor, vel lacinia enim. Pellentesque posuere a urna eget fermentum. Vivamus tincidunt varius
turpis, eget suscipit arcu aliquam vel. Maecenas fermentum tellus vel euismod porttitor. Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod. Praesent nibh leo, auctor vel porttitor in, auctor et sapien. Nullam et
nulla rutrum, convallis tellus vitae, eleifend massa</p>
</div>
</div>
</div>
<div class="acc">
<h3>Question 1: What is?</h3>
<div class="fqcontent">
<div class="content-inner">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien turpis, tincidunt nec maximus et, elementum vel massa. Sed quis suscipit tortor, vel lacinia enim. Pellentesque posuere a urna eget fermentum. Vivamus tincidunt varius
turpis, eget suscipit arcu aliquam vel. Maecenas fermentum tellus vel euismod porttitor. Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod. Praesent nibh leo, auctor vel porttitor in, auctor et sapien. Nullam et
nulla rutrum, convallis tellus vitae, eleifend massa</p>
</div>
</div>
</div>
<div class="acc">
<h3>Question 1: What is?</h3>
<div class="fqcontent">
<div class="content-inner">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien turpis, tincidunt nec maximus et, elementum vel massa. Sed quis suscipit tortor, vel lacinia enim. Pellentesque posuere a urna eget fermentum. Vivamus tincidunt varius
turpis, eget suscipit arcu aliquam vel. Maecenas fermentum tellus vel euismod porttitor. Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod. Praesent nibh leo, auctor vel porttitor in, auctor et sapien. Nullam et
nulla rutrum, convallis tellus vitae, eleifend massa</p>
</div>
</div>
</div>
</div>
<!-------------Footer----------->
<footer>
<div class="footer">
<nav>
<ul>
<li><a href="">Log In</a></li>
<li><a href="">FAQ</a></li>
<li><a href="">My Surveys</a></li>
</ul>
</nav>
</div>
</footer>
<script src="main.js"></script>
</body>
</html>
最佳答案
这就是您需要在您的 CSS 中更改/添加的内容:
/*-------------login-----------*/
.login-box{
position: relative;
height: 100vh;
}
#login-box {
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
您的登录部分 (.login-box) 的父 div 需要一个“位置”值(例如:position: relative),然后您的登录框会在内部 .login-box。
对于背景图片,您必须为父 div 设置特定的高度。
如果您在 .login-box div 中使用图像标签,则该 div 将与图像本身一样高
运行示例(完整代码):
html body {
margin: 0;
padding: 0;
}
body {
height: 100%;
background-color: black !important;
}
/*-------------header-----------*/
header {
height: 110px;
line-height: 110px;
position: fixed;
z-index: 1;
width: 100%;
}
.secondary {
background-color: darkorange;
box-shadow: 0px 0px 15px 0px;
transition: all 0.5s ease-in-out;
}
/*-------------nav-----------*/
ul {
list-style: none;
}
ul li {
display: inline-block;
}
header nav {
float: right;
}
.logo img {
margin-top: -20px;
height: 30px;
}
header nav ul li a {
padding-right: 25px;
font-weight: bold;
color: white;
transition: all 0.5s ease-in;
}
header nav ul li a:hover {
text-decoration: none;
color: black;
}
/*-------------slider-----------*/
.img1 {
background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.7)), url(http://lorempixel.com/1920/1080/);
background-size: 100% 100%;
}
.slider,
.slider ul,
.slider ul li {
height: 100%;
width: 100%;
color: white;
text-align: center;
padding: 0px;
}
.slider h2 {
font-weight: bold;
margin-top: 260px;
}
.slider span {
color: orange;
}
.slider a {
padding: 10px 40px;
margin-right: 10px;
}
/*-------------slider-button-----------*/
.slider a.btn-half {
background-color: orange;
color: white;
width: 200px;
}
.slider a.btn-half:hover {
opacity: 0.7;
transition: 0.5s ease-in;
}
.img2 {
background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.7)), url(http://lorempixel.com/1920/1080/);
background-size: 100% 100%;
}
.img3 {
background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.7)), url(http://lorempixel.com/1920/1080/);
background-size: 100% 100%;
}
.slider i {
font-size: 30px;
margin-right: 10px;
}
/*-------------login-----------*/
.login-box{
position: relative;
height: 100vh;
}
#login-box {
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}
.login-box h1 {
width: 100px;
font-size: 40px;
border-bottom: 6px solid darkorange;
margin-bottom: 50px;
padding: 13 px 0;
}
.textbox {
width: 100%;
overflow: hidden;
font-size: 20px;
padding: 8px 0;
margin: 8px 0;
border-bottom: 1px solid darkorange;
}
.textbox i {
width: 26px;
float: left;
text-align: center;
}
.textbox input {
border: none;
outline: none;
background: none;
color: white;
font-size: 17px;
width: 80%;
float: left;
margin: 0 10px;
}
.btn {
width: 100%;
background: none;
border: 2px solid darkorange;
color: white;
padding: 5px;
font-size: 17px;
cursor: pointer;
margin: 12px 0;
}
.btn:hover {
opacity: 0.7;
transition: 0.5s ease-in;
}
/*-------------FAQ-----------*/
.fqcontainer {
max-width: 60%;
margin: 0 auto;
padding: 70px 0 20px;
width: 100%;
}
.fqcontainer h1 {
text-align: center;
font-family: 'roboto', 'sans-serif';
font-size: 60px;
margin: 50px 0 0;
color: white;
}
.acc {
border-bottom: 1px solid white;
}
.acc h3 {
font-size: 25px;
background-color: black rgba(0, 0, 0, 0.6);
color: white;
padding: 15px;
margin: 0;
cursor: pointer;
font-family: 'roboto', 'sans-serif';
letter-spacing: 2px;
position: relative;
}
.acc h3:after {
content: '+';
position: absolute;
right: 20px;
font-size: 40px;
top: 50%;
transform: translateY(-50%);
}
.acc.active h3:after {
content: '-';
}
.fqcontent {
background-color: white;
margin-top: 0;
line-height: 1.5;
display: none;
}
.content-inner {
padding: 15px;
}
/*-------------footer-----------*/
.footer {
width: 100%;
background-color: darkorange;
padding: 50px 0px;
}
footer nav {
text-align: center;
}
footer nav ul li a {
padding-right: 25px;
font-weight: bold;
color: white;
transition: all 0.5s ease-in;
}
footer nav ul li a:hover {
text-decoration: none;
color: black;
}
/* CHANGES */
.slider {
overflow: hidden;
max-height: 100vh;
}
<body>
<!-------------Header/Nav----------->
<header>
<div class="container">
<div class="row">
<a href="index.html" class="logo"><img src="logo.png"></a>
<nav>
<ul>
<li><a href="#login-box">Log In</a></li>
<li><a href="">FAQ</a></li>
<li><a href="">My Surveys</a></li>
</ul>
</nav>
</div>
</div>
</header>
<!-------------Slider----------->
<section class="slider">
<ul class="slider-carousel" id="slider-carousel">
<li class="img1">
<h2>Slider<span>Slider</span></h2>
<p>Hello World</p>
<i class="fab fa-apple"></i>
<i class="fab fa-android"></i>
<i class="fab fa-windows"></i>
<p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
</p><br>
<a href="" class="btn btn-half">Get Started</a>
</li>
<li class="img2">
<h2>Slider<span>Slider</span></h2>
<p>Hello World</p>
<i class="fab fa-apple"></i>
<i class="fab fa-android"></i>
<i class="fab fa-windows"></i>
<p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
</p><br>
<a href="" class="btn btn-half">Get Started</a>
</li>
<li class="img3">
<h2>Slider<span>Slider</span></h2>
<p>Hello World</p>
<i class="fab fa-apple"></i>
<i class="fab fa-android"></i>
<i class="fab fa-windows"></i>
<p><br>Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod.Praesent nibh leo, auctor vel po rttitor in, auctor et sapien.<br> Nullam et nulla rutrum, convallis tellus vitae, eleifend massa
</p><br>
<a href="" class="btn btn-half">Get Started</a>
</li>
</ul>
</section>
<!-------------Login----------->
<div class="login-box">
<div id="login-box">
<h1>Login</h1>
<div class="textbox">
<i class="fas fa-user"></i>
<input type="text" placeholder="Username" name="" value="">
</div>
<div class="textbox">
<i class="fas fa-lock"></i>
<input type="text" placeholder="Password" name="" value="">
</div>
<input class="btn" type="button" name="" value="Sign In">
</div>
</div>
<!-------------FAQ----------->
<div class="fqcontainer">
<h1>FAQ Section</h1>
<div class="acc">
<h3>Question 1: What is?</h3>
<div class="fqcontent">
<div class="content-inner">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien turpis, tincidunt nec maximus et, elementum vel massa. Sed quis suscipit tortor, vel lacinia enim. Pellentesque posuere a urna eget fermentum. Vivamus tincidunt varius turpis,
eget suscipit arcu aliquam vel. Maecenas fermentum tellus vel euismod porttitor. Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod. Praesent nibh leo, auctor vel porttitor in, auctor et sapien. Nullam et nulla rutrum, convallis
tellus vitae, eleifend massa</p>
</div>
</div>
</div>
<div class="acc">
<h3>Question 1: What is?</h3>
<div class="fqcontent">
<div class="content-inner">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien turpis, tincidunt nec maximus et, elementum vel massa. Sed quis suscipit tortor, vel lacinia enim. Pellentesque posuere a urna eget fermentum. Vivamus tincidunt varius turpis,
eget suscipit arcu aliquam vel. Maecenas fermentum tellus vel euismod porttitor. Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod. Praesent nibh leo, auctor vel porttitor in, auctor et sapien. Nullam et nulla rutrum, convallis
tellus vitae, eleifend massa</p>
</div>
</div>
</div>
<div class="acc">
<h3>Question 1: What is?</h3>
<div class="fqcontent">
<div class="content-inner">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sapien turpis, tincidunt nec maximus et, elementum vel massa. Sed quis suscipit tortor, vel lacinia enim. Pellentesque posuere a urna eget fermentum. Vivamus tincidunt varius turpis,
eget suscipit arcu aliquam vel. Maecenas fermentum tellus vel euismod porttitor. Curabitur sodales sem nec nisl finibus, nec suscipit magna euismod. Praesent nibh leo, auctor vel porttitor in, auctor et sapien. Nullam et nulla rutrum, convallis
tellus vitae, eleifend massa</p>
</div>
</div>
</div>
</div>
<!-------------Footer----------->
<footer>
<div class="footer">
<nav>
<ul>
<li><a href="">Log In</a></li>
<li><a href="">FAQ</a></li>
<li><a href="">My Surveys</a></li>
</ul>
</nav>
</div>
</footer>
<script src="main.js"></script>
</body>
</html>
关于html - 如何在不重叠网页内容的情况下减小背景图片的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54953048/
我对具有 2 个轴的数据有交叉识别问题,例如 A = array([['x0', 'y0', 'data0', 'data0'], ['x0', 'y0', 'data0', '
我知道这是代码有点傻,但有人可以解释为什么 isList [42]返回 True而isList2 [42]打印 False ,以及如何防止这种情况?我想更好地理解一些更晦涩的 GHC 类型扩展,我认为
我正在使用memmove(),但目标似乎正在覆盖源,或者也许我不明白覆盖是什么。我有一个 char 数组(目标),然后是一个指向目标的指针,该指针位于 vector 内部。 char destinat
以下AS3代码有时会导致音频多次播放,就像疯狂的回声一样,几乎同时播放。通常使用该URL都可以,但是当我使用https://soundcloud.com url时,它总是会发疯。在极少数情况下,我认为
我正在尝试在 android 2.2 中实现类似操作栏的东西。这是我的 main.xml
如何避免第一个值的重叠问题 而且,我怎样才能看到最后一个被剪裁的值? 最佳答案 我认为您在修改轴上的样式和调整视口(viewport)之间有几种选择。 我会尝试: 禁用左轴,启用右轴 chart.le
我正在构建一个简单的应用程序,您可以在其中使用纸娃娃之类的工具来描述您的外观。 Check out this image.计划是有 4 个水平 ScrollView :第一个用于发型,第二个用于面部毛
我有一个问题...我在绝对布局中有两个 ScrollView 。换句话说,它们是全屏的并且相互重叠 上面的scrollview是水平滚动的,下面的是垂直滚动的scrollview。 当我水平滚动时,我
我看了一些类似的问题,但我不太明白在我的层次结构中我应该做什么? 我有 用于屏幕底部的标签菜单 和 对于其他将创建的 fragment 。 我有 9 个标签菜单,每个都是 fragment 。 一
在我的 Android 应用程序中,我有一个编辑文本和一个按钮,单击该按钮会向我的主要 Activity 添加一个 fragment ,其中包含在我的编辑文本中写入的消息。问题是,当我更改消息并单击按
在我的分段控件中,有时标题比其段宽。我怎样才能让它截断? 假设第 1 段的标题是 Text overlaps,第 2 段的名称是 ok。 我希望它看起来如何: [Text ov...| ok
我想创建一个带有重叠单元格的 uitableview,如下图所示。问题是,即使我为单元格的内容 View 设置 clipsToBounds = NO,单元格假标题(例如,将与前一个单元格重叠的西类牙语
有了这个CSS .addProblemClass{ width:300px; height:300px; /*width:25%; height:40%;*/
我有跨窗口移动的图像(2 行),当我离开页面选项卡时,然后返回它,所有图像都相互堆叠。 JS代码(记入jfriend00) function startMoving(img) { va
这是我的一段代码。图像在 23 毫秒后正常可见,但永远不会像第二行所示那样返回隐藏状态。如果我将其从 17 毫秒更改为大于 23 毫秒的值,它就会起作用。反之亦然,如果我将第一行更改为 16 毫秒,它
我正在可汗学院为学校项目编写一款太空入侵者游戏,但我不知道如何在子弹和外星人之间进行碰撞,然后摆脱子弹所碰撞的外星人。这是非常基本的 JS,尽管我尝试过,但我不太明白如何将有关该主题的其他答案放入我的
当我尝试重新加载 tableView 的数据时出现奇怪的重叠,导致单元格的高度发生变化(使用 UITableViewAutomaticDimension),然后内容与上面的单元格重叠,无法弄清楚怎么做
我是一个新手,如果这是一个愚蠢的问题,请原谅我。我想有一个部分与标题分开,但发生了两种情况: (1) 当我把 在 下面,它们相互重叠,如下所示: Section overlapping header
我正在尝试创建两个 那是重叠的。唯一的问题是第二个 在第一个的前面它必须是相反的。我尝试设置第一个 的 z-index至 1但它仍然不起作用。 这是我的代码: #content{ backgrou
是否有重叠 2 个 div 的有效方法。 我有以下内容,但无法让它们重叠。 #top-border{width:100%; height:60px; background:url(image.jpg)
我是一名优秀的程序员,十分优秀!