CSS 形状创建曲线波

2023-12-11

How this Css shapes are created

这就是我到目前为止所得到的 查看教程后

  • I want know how curved effect is generated on divs the only question that i found near to what i was looking for was At here at stackoverlow but that too dint help enter image description here
  • 上图的折边效果是如何制作的

Css

#MenuShape{
   height:50px;
   background-color:orange; 
   width:200px;
    position:relative;
    text-align:center;
    left:100px;

}
#MenuShape:after{
        content:"";
   position: absolute;
    width: 0;
   height: 0;
   left:200px;
  border-top: 50px solid transparent;
    border-left: 100px solid orange;
    border-bottom: 0px solid transparent;

}
#MenuShape:before{
        content:"";
   position: absolute;
    width: 0;
   height: -50;
   left:-100px;
  border-top: 50px solid transparent;
    border-right: 100px solid orange;
    border-bottom: 0px solid transparent;

}

HTML

<div id="MenuShape"  >
    sachin

</div>

https://css-tricks.com/这是检查它的网站,我发现它的跨度被包裹住了 锚标记和 svg 标记

  <a href="/" class="home">
    <svg viewBox="0 0 100 25" class="shape-tab">
      <use xlink:href="#shape-tab"></use>
    </svg>

  <span>Blog</span></a>

单击此处查看它在 codepen 中正常工作的意外行为


这里有一个最终演示 (archived)在折叠角上:

以下代码是创建它们的方法:

.note {
  position: relative;
  width: 30%;
  padding: 1em 1.5em;
  margin: 2em auto;
  color: #fff;
  background: #97C02F;
  overflow: hidden;
}

.note:before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-width: 0 16px 16px 0;
  border-style: solid;
  border-color: #fff #fff #658E15 #658E15;
  background: #658E15;
  -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
  -moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
  /* Firefox 3.0 damage limitation */
  display: block;
  width: 0;
}

.note.rounded {
  -moz-border-radius: 5px 0 5px 5px;
  border-radius: 5px 0 5px 5px;
}

.note.rounded:before {
  border-width: 8px;
  border-color: #fff #fff transparent transparent;
  -moz-border-radius: 0 0 0 5px;
  border-radius: 0 0 0 5px;
}
<div class="note"></div>

要创建弯曲的波浪效果,您可以使用以下代码:

#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;
}
<div id="wave"></div>

为了获得曲线,您需要反转它的起始位置。遵循相同的演示,只是颠倒你的价值观。

See a 现场演示 (archived)了解边框半径如何创建您想要的形状和效果并调整每个角以查看其实际效果。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

CSS 形状创建曲线波 的相关文章

随机推荐