0

我正在wavy header我的网站上制作一个,我试图让它看起来像这样。

在此处输入图像描述

但相反,我在我的网站上得到了这个。

在此处输入图像描述

我尝试更改className但仍然无法正常工作,这是我的代码:App.js:

function App() {
  return (
  <div className="App">
    <div className="Wave-container">
      <h1>Hello, world!</h1>
      <p>Check out my awesome waves!</p>
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">
      <path fill="#FFF" d="M0 54.6508V452.104C45.5 452.104 166.824 392.806 306 452.104C401.5 492.794 424.14 456.282 518 388.81C648.5 294.998 708.5 317.038 766.5 317.038C894.591 317.038 866.439 410.314 983 371.856C1159.5 313.622 1205.16 278.703 1271 245.267C1353 203.621 1373 202.317 1440 150.349V115.746V0H1400C1360 0 1280 0 1200 0C1120 0 1040 0 960 0C880 0 800 0 720 0C640 0 560 0 480 0C400 0 320 0 240 0C160 0 80 0 40 0H0V54.6508Z">
      </path>  
      </svg>
    </div>
  </div>
  );
}

应用程序.css:

.Wave-container {
  position: relative;
  background: #09F;
  color: #FFF;
  text-align: center;
  overflow: hidden;
}
h1 {
  font-size: 5rem;
  margin: 7rem 1.25rem 2.5rem 1.25rem;
}
p {
  font-size: 1.5rem;
  margin: 0 1.25rem 5rem 1.25rem;
}

之前谢谢,任何帮助将不胜感激

4

3 回答 3

1

您可以通过更改其值来编辑视图框。

<svg xmlns="http://www.w3.org/2000/svg" **viewBox="100 200 1200 350"**>
于 2020-05-16T07:31:04.750 回答
1

HTML

    <html>
  <head>
    <meta charset="utf-8">
    <title> Title</title>
    <link rel='stylsheet' href='style.css'>
  </head>
  <body>
  <section class="wave"></section>
  </body>
</html>

CSS

body {
  margin: 0;
  padding:0;
}
section {
  width: 100%;
  min-height: 1000px;
}
.wave{
  position: relative;
  background: red
}
.wave:before{
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  Height: 150px;
  background: url(--url of the wave opacity map);
  background-size: cover;
  background-repeat: no-repeat;
}

您可以使用此地图wave.png或创建自己的地图。

于 2020-05-16T07:54:57.150 回答
1

另一种方法。

CSS

#wave {
  position: relative;
  height: 70px;
  width: 600px;
  background: #e0efe3;
}

#wave:before {
        content: "";
        display: block;
        position: absolute;
        border-radius: 100% 50%;
        width: 340px;
    height: 80px;
    background-color: white;
    right: -5px;
    top: 40px;
}

#wave:after {
        content: "";
        display: block;
        position: absolute;
        border-radius: 100% 50%;
        width: 300px;
    height: 70px;
    background-color: #e0efe3;
    left: 0;
    top: 27px;
}

HTML

<div id="wave"/>
<div/>
于 2020-05-16T07:56:38.853 回答