我一直在尝试如何添加背景图片和滑动部分/文本。到目前为止,我只有图片附加到部分,但我认为我的方式写我的js是混乱的事情。我知道这是一个更好的做法,把图片作为背景在css,但我仍然是一个新手,只是想让我的着陆页整洁。
这是我的第一个项目。任何帮助都很感激。
(https://codepen.io/Robertthegreat12/pen/XWGbVbr)
section {
display: grid;
align-content: center;
place-items: center;
font-family: 'Times New Roman', Times, serif;
min-height: 100vh;
font-weight: 600;
font-size: xx-large;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
min-height: 100vh;
background-color: #131316;
color: #ffffff;
}
img {
max-width: 500px;
height: auto;
max-width: 600px;
}
.btn-posnawr {
color: #192022;
position: relative;
display: block;
overflow: hidden;
width: 100%;
height: auto;
max-width: 250px;
border-radius: 8px;
margin: 1rem auto;
font: normal 18px/60px 'proxima-nova', sans-serif;
text-align: center;
text-decoration: none;
border: 2px solid #ffffff;
}
.btn-posnawr span {
position: absolute;
display: block;
width: 0;
height: 0;
border-radius: 50%;
background-color: #00abec;
-webkit-transition: width 0.4s ease-in-out, height 0.4s ease-in-out;
transition: width 0.4s ease-in-out, height 0.4s ease-in-out;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: -1;
}
.btn-posnawr:hover {
color: #eee;
}
.btn-posnawr:hover span {
width: 225%;
height: 562.5px;
}
.btn-posnawr:active {
background-color: #00c4ad;
}
.box {
opacity: 0;
filter: blur(4px);
transition: all 1s;
transform: translateX(-100%);
}
.show {
opacity: 1;
filter: blur(0);
transform: translateX(0);
}
#slide1 {
background-image: url();
}
个字符
我试着把ID放在部分,并试图修改它,但它没有做任何事情。
1条答案
按热度按时间wpx232ag1#
要为每个部分添加背景图像,除了第一个部分,请使用
nth-child
选择器的background
属性。这也避免了手动为每个部分添加ID和图像标记的需要。字符串
要针对特定部分(如第3部分):
型
下面是完整的代码:
x
的一种或多种
参考文件: