我試圖在我的網站上添加一個svg漸變背景圖像,但是,當添加SVG作為背景時,它似乎只是隨機復制了多次。我以前在添加背景圖片時從來沒有遇到過這個問題,不知道為什么現在不行了。
我已經嘗試添加背景沒有重復就行了。然而,這并不能解決問題。
{
color: white;
text-align: center;
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-image: url(./color-morph.svg);
}
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 20px 100px;
background: rgba(255, 255, 255, .1);
display: flex;
justify-content: space-between;
align-items: center;
backdrop-filter: blur(10px);
border-bottom: 2px solid rgba(255, 255, 255, .2);
}
.navbar a {
font-size: 18px;
text-decoration: none;
margin-left: 35px;
transition: .3s;
}
.navbar a:hover {
color: black;
-webkit-text-stroke: 1px white;
}
.container {
display: inline-block;
margin: 0 auto;
padding-top: 15%;
}
.text {
font-size: 30px;
font-weight: 900;
letter-spacing: 5px;
border-right: 5px solid;
width: 100%;
white-space: nowrap;
overflow: hidden;
animation:
typing 2s steps(17),
cursor .4s step-end infinite alternate;
}
/* cursor blinking effect */
@keyframes cursor {
50% {
border-color: transparent;
}
}
/* Typewriter effect */
@keyframes typing {
from {
width: 0
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header class="header">
<a href="#" class="logo">Matt</a>
<nav class="navbar">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Contact</a>
<a href="#">Projects</a>
</nav>
</header>
<div class="container">
<p class="text">Hello, Matt Here.</p>
</div>
</body>
</html>
你必須說,圖像不會重復自己,它覆蓋了整個屏幕
試試這個:(更新)
body {
background-image: url(./color-morph.svg);
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}