CSS背景与多次重复的SVG

huangapple go评论136阅读模式
英文:

CSS Background with svg duplicating multiple times

问题

I am trying to add a svg gradient background image to my website, however, When adding the SVG as a background it just seems to duplicate it multiple times randomly. I have never had this issue before when adding background images, not sure why it is not working now.

我正在尝试将SVG渐变背景图像添加到我的网站,但是,将SVG添加为背景时,它似乎会随机多次重复。在以前添加背景图像时从未遇到过这个问题,不确定为什么现在不起作用。

I have tried adding background no repeat on the line after. However this doesn't fix the issue.

我尝试在下一行添加"background no repeat",但是这并没有解决问题。

英文:

I am trying to add a svg gradient background image to my website, however, When adding the SVG as a background it just seems to duplicate it multiple times randomly. I have never had this issue before when adding background images, not sure why it is not working now.
CSS背景与多次重复的SVG

I have tried adding background no repeat on the line after. However this doesn't fix the issue.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

  1. {
  2. color: white;
  3. text-align: center;
  4. box-sizing: border-box;
  5. margin: 0;
  6. padding: 0;
  7. }
  8. body {
  9. background-image: url(./color-morph.svg);
  10. }
  11. .header {
  12. position: fixed;
  13. top: 0;
  14. left: 0;
  15. width: 100%;
  16. padding: 20px 100px;
  17. background: rgba(255, 255, 255, .1);
  18. display: flex;
  19. justify-content: space-between;
  20. align-items: center;
  21. backdrop-filter: blur(10px);
  22. border-bottom: 2px solid rgba(255, 255, 255, .2);
  23. }
  24. .navbar a {
  25. font-size: 18px;
  26. text-decoration: none;
  27. margin-left: 35px;
  28. transition: .3s;
  29. }
  30. .navbar a:hover {
  31. color: black;
  32. -webkit-text-stroke: 1px white;
  33. }
  34. .container {
  35. display: inline-block;
  36. margin: 0 auto;
  37. padding-top: 15%;
  38. }
  39. .text {
  40. font-size: 30px;
  41. font-weight: 900;
  42. letter-spacing: 5px;
  43. border-right: 5px solid;
  44. width: 100%;
  45. white-space: nowrap;
  46. overflow: hidden;
  47. animation:
  48. typing 2s steps(17),
  49. cursor .4s step-end infinite alternate;
  50. }
  51. /* cursor blinking effect */
  52. @keyframes cursor {
  53. 50% {
  54. border-color: transparent;
  55. }
  56. }
  57. /* Typewriter effect */
  58. @keyframes typing {
  59. from {
  60. width: 0
  61. }
  62. }

<!-- language: lang-html -->

  1. &lt;!DOCTYPE html&gt;
  2. &lt;html lang=&quot;en&quot;&gt;
  3. &lt;head&gt;
  4. &lt;meta charset=&quot;UTF-8&quot;&gt;
  5. &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;
  6. &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;ie=edge&quot;&gt;
  7. &lt;title&gt;Website&lt;/title&gt;
  8. &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
  9. &lt;/head&gt;
  10. &lt;body&gt;
  11. &lt;header class=&quot;header&quot;&gt;
  12. &lt;a href=&quot;#&quot; class=&quot;logo&quot;&gt;Matt&lt;/a&gt;
  13. &lt;nav class=&quot;navbar&quot;&gt;
  14. &lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;
  15. &lt;a href=&quot;#&quot;&gt;About&lt;/a&gt;
  16. &lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;
  17. &lt;a href=&quot;#&quot;&gt;Projects&lt;/a&gt;
  18. &lt;/nav&gt;
  19. &lt;/header&gt;
  20. &lt;div class=&quot;container&quot;&gt;
  21. &lt;p class=&quot;text&quot;&gt;Hello, Matt Here.&lt;/p&gt;
  22. &lt;/div&gt;
  23. &lt;/body&gt;
  24. &lt;/html&gt;

<!-- end snippet -->

答案1

得分: 0

请查看以下翻译内容:

"你必须说图像不会重复出现,并且覆盖整个屏幕

尝试这个:(已更新)

  1. body {
  2. background-image: url(./color-morph.svg);
  3. background-repeat: no-repeat;
  4. background-size: cover;
  5. background-attachment: fixed;
  6. }
  7. ```"
  8. <details>
  9. <summary>英文:</summary>
  10. You must say that the image does not repeat itself and that it covers the entire screen
  11. Try this : (updated)
  12. body {
  13. background-image: url(./color-morph.svg);
  14. background-repeat: no-repeat;
  15. background-size: cover;
  16. background-attachment: fixed;
  17. }
  18. </details>

huangapple
  • 本文由 发表于 2023年5月15日 05:46:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76249811.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定