コニファ・ロゴ

csstest:[CSS]svgを使い、アニメーションする波をテキストで切り抜きタイトルを強調

CSSとsvgを使い、アニメーションする波をテキストで切り抜いてタイトルを強調します。次のサンプルのテキスト「BtoB WEB」で切り抜いた部分が波のように動きます。

 

BtoB WEB 受注システム

 

サンプルのhtmlソース

  1. <div class="center">
  2. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="800" height="220" xml:space="preserve">
  3. <pattern id="water" width=".25" height="1.1" patternContentUnits="objectBoundingBox">
  4. <path fill="#fff" d="M0.25,1H0c0,0,0-0.659,0-0.916c0.083-0.303,0.158,0.334,0.25,0C0.25,0.327,0.25,1,0.25,1z"/>
  5. </pattern>
  6. <g>
  7. <text id="text" x="115" y="150" style="font-weight:bold;font-size: 98pt; font-family:helvetica">BtoB WEB</text>
  8. </g>
  9. <mask id="text-mask">
  10. <use x="0" y="0" xlink:href="#text" opacity="1" fill="#ffffff"/>
  11. </mask>
  12. <g id="eff">
  13. <use x="0" y="0" xlink:href="#text" fill="#69a8c9"/>
  14. <rect class="water-fill" mask="url(#text-mask)" fill="url(#water)" x="-300" y="100" width="1200" height="120" opacity="0.3">
  15. <animate attributeType="xml" attributeName="x" from="-300" to="0" repeatCount="indefinite" dur="3s"/>
  16. </rect>
  17. <rect class="water-fill" mask="url(#text-mask)" fill="url(#water)" y="95" width="1600" height="120" opacity="0.3">
  18. <animate attributeType="xml" attributeName="x" from="-400" to="0" repeatCount="indefinite" dur="4s"/>
  19. </rect>
  20. <rect class="water-fill" mask="url(#text-mask)" fill="url(#water)" y="105" width="800" height="120" opacity="0.3">
  21. <animate attributeType="xml" attributeName="x" from="-200" to="0" repeatCount="indefinite" dur="2.4s"/>
  22. </rect>
  23. <rect class="water-fill" mask="url(#text-mask)" fill="url(#water)" y="105" width="2000" height="120" opacity="0.3">
  24. <animate attributeType="xml" attributeName="x" from="-500" to="0" repeatCount="indefinite" dur="3.8s"/>
  25. </rect>
  26. </g>
  27. <use xlink:href="#eff" opacity="0.9"/>
  28. </svg>
  29. <span>受注システム</span>
  30. </div>

サンプルのCSSソース

  1. .center {
  2. width: 800px;
  3. height: 350px;
  4. margin: 0 auto;
  5. background: #15b;
  6. text-align: center;
  7. position: relative;
  8. }
  9. .center span {
  10. font-size: 90px;
  11. font-weight: bold;
  12. color: #48e;
  13. position: relative;
  14. top: -30px;
  15. }
  16. svg {
  17. display: block;
  18. position: relative;
  19. left: -40px;
  20. }

 

戻るボタン