イセンチュートリアルサイト
  • CSS
    • スクロールダウン
    • テキストナビゲーション
    • ボタン
    • メニュー
    • 動画
    • 検索
    • 画像リンクの動き
    • 背景の動き
  • Illustrator
  • JS
    • アコーディオンパネル
    • アニメーション
    • エリアの動き
    • ギャラリー
    • グラフ
    • スライド
    • テキストの動き
    • ニュースティッカー
    • ページトップリンク
    • ページ内リンク
    • メニュー
    • モーダルウィンドウ
    • ローディング
  • Photoshop
  • PHP
  • WordPress
    • プラグイン
    • リンク
  • お客様観覧用
    • WEB制作プラン
    • アニメーション
    • グローバルナビゲーション
    • スライド
  • サーバー
    • CPI
  • 未分類
  • 法律
    • 医療法
    • 柔道整復師法
TOP CSS 背景の動き

CSS

カテゴリーページ

  • 粒子が集まってタイポグラフィーを形成する

    カテゴリー:背景の動き


     

    HTMLの書き方

    head終了タグ直前に自作のCSSを読み込みます。

    <link rel="stylesheet" type="text/css" href="css/5-17.css">

    body内の粒子を表示させたい場所にHTMLを記載します。

    <div id="wrapper">
    <canvas id="particle"></canvas>
    <!--/wrapper--></div>

    body終了タグ直前に jQuery、particleText.jsと、動きを制御する自作のJS の3 つを読み込みます。

    <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
    <script src="js/particleText.js"></script><!--https://github.com/55Kaerukun/particleText.jsからダウンロードして使用-->
    <!--自作のJS-->
    <script src="js/5-17.js"></script>

     

    CSSの書き方
    画面全体に効果を設定したい場合は、下記のように設定する。

    #wrapper{
    	/*描画されるテキストを中央寄せにする*/
    	display:flex;
    	justify-content: center;
    	align-items: center;
    }
    
    #particle{
    	width:100%;
    	height: 100vh;
    	vertical-align: bottom;/*canvasタグ下に余白が生まれるのを防ぐ*/
    }
    

     

    JSの書き方

    $("#particle").particleText({
    	text: "If you can dream it<br>you can do it.<br>日本語もいけるよ", // 表示させたいテキスト。改行の場合は<br>追加
    	colors:[ "#fff","#ccc", "#ddd" ], // パーティクルの色を複数指定可能
    	speed: "high", // slow, middle, high の3つから粒子が集まる速さを選択
    });
    

    ※テキストが横に長いと画面からはみ出て非表示になります。その場合は改行を利用して表示させます。
    ※particleText.js本体の中では、font-familyの指定や、粒子の数の指定が出来ます。
    レイアウトによって調整してください。

    投稿日:2022年08月03日
  • 水滴が落ちる

    カテゴリー:背景の動き


     

    HTMLの書き方

    head終了タグ直前に自作のCSSを読み込みます。

    <link rel="stylesheet" type="text/css" href="css/5-16.css">

    body内の水滴を表示させたい場所にHTMLを記載します。

    <div id="wrapper">
    <!--/wrapper--></div>

    body 終了タグ直前に jQuery、jQuery UI、raindrops.jsと、動きを制御する自作のJS の4 つを読み込みます。

    <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
    <script
    src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"
    integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30="
    crossorigin="anonymous"></script>
    <script src="js/raindrops.js"></script><!--Raindrops.js(https://daniellaharel.com/raindrops/)からダウンロードして使用-->
    <!--自作のJS-->
    <script src="js/5-16.js"></script>

     

    JSの書き方
    水滴を描画したい要素のIDを指定します。

    jQuery('#wrapper').raindrops(//指定したエリアに描画
    	{
    	color:'#A5D2DA',//水の色を指定
    	canvasHeight:150, //canvasの高さを指定。初期値は親の高さの50%。
    	waveLength: 100,//波の長さ(広がり)を指定。数値が大きいほど長さは小さくなる。初期値は340。
    	waveHeight:200,//波の高さを指定。数値が大きいほど高さは高くなる。初期値は100。
    	rippleSpeed: 0.05, //波紋のスピードを指定。数値が大きいほど波紋は速くなる。初期値は0.1。
    	density: 0.04,//水の波紋の量を指定。数値が大きいほど波紋は小さくなる。初期値は0.02。
    	frequency:5//雨粒の落ちる頻度を指定。数値が大きいほど頻度は多くなる。初期値は3。
    	}
    );
    投稿日:2022年08月03日
  • 波線(複数)

    カテゴリー:背景の動き


     

    HTMLの書き方

    head終了タグ直前に自作のCSSを読み込みます。

    <div class="wave"><canvas id="waveCanvas"></canvas></div>

    body内の波を表示させたい場所にHTMLを記載します。

    <canvas id="waveCanvas"></canvas>
    
    <!--↓波を増やしたい場合は、idを別にしてcanvasタグを追加していく-->
    
    <canvas id="waveCanvas2"></canvas>
    <canvas id="waveCanvas3"></canvas>

    body 終了タグ直前に動きを制御する自作のJS を読み込みます。

    <script src="js/5-15.js"></script>

     

    CSSの書き方

    高さを持たせた親要素の中に設置すると描画されます。
    特定の要素の下部に波を入れたい時は、親要素に配置の基点となるposition:relative;をつけ<canvas>タグを絶対配置でbottom:0;に指定します。

    (例)

    <div class="wave">
    	<canvas id="waveCanvas"></canvas>
    </div>
    
    .wave{
    	position:relative;
    	height:200px;/*何も表示されない場合は各波の親要素に高さを持たせましょう。*/
    }
    canvas{
    	position: absolute;
    	bottom: 0;
    	left:0;
    	width: 100%;
    }
    

     

    JSの書き方

    var unit = 100,
    canvasList, // キャンバスの配列
    info = {}, // 全キャンバス共通の描画情報
    colorList; // 各キャンバスの色情報
    
    /**
     * Init function.
     * 
     * Initialize variables and begin the animation.
     */
    function init() {
    	info.seconds = 0;
    	info.t = 0;
    	canvasList = [];
    	colorList = [];
    	
    	// canvas1個めの色指定
    	canvasList.push(document.getElementById("waveCanvas"));
    	colorList.push(['#0ff', '#ff0', '#f00', '#00f', '#f0f']);//重ねる波線の色設定
        
    	// canvas2個めの色指定
    	canvasList.push(document.getElementById("waveCanvas2"));
    	colorList.push(['#43c0e4']);
        
    	// canvas3個めの色指定
    	canvasList.push(document.getElementById("waveCanvas3"));
    	colorList.push(['#666', '#888']);
    
    	// 各キャンバスの初期化
    	for(var canvasIndex in canvasList) {
    		var canvas = canvasList[canvasIndex];
    		canvas.width = document.documentElement.clientWidth; //Canvasのwidthをウィンドウの幅に合わせる
    		canvas.height = 200;//波の高さ
    		canvas.contextCache = canvas.getContext("2d");
    	}
    	// 共通の更新処理呼び出し
    	update();
    }
    
    function update() {
    	for(var canvasIndex in canvasList) {
    		var canvas = canvasList[canvasIndex];
    		// 各キャンバスの描画
    		draw(canvas, colorList[canvasIndex]);
    	}
    	// 共通の描画情報の更新
    	info.seconds = info.seconds + .014;
    	info.t = info.seconds*Math.PI;
    	// 自身の再起呼び出し
    	setTimeout(update, 35);
    }
    
    /**
     * Draw animation function.
     * 
     * This function draws one frame of the animation, waits 20ms, and then calls
     * itself again.
     */
    function draw(canvas, color) {
    	// 対象のcanvasのコンテキストを取得
    	var context = canvas.contextCache;
    	// キャンバスの描画をクリア
    	context.clearRect(0, 0, canvas.width, canvas.height);
    
    	//波を描画 drawWave(canvas, color[数字(波の数を0から数えて指定)], 透過, 波の幅のzoom,波の開始位置の遅れ )
    	drawWave(canvas, color[0], 0.8, 3, 0);
    	drawWave(canvas, color[1], 0.5, 4, 0);
    	drawWave(canvas, color[2], 0.3, 1.6, 0);
    	drawWave(canvas, color[3], 0.2, 3, 100);
    	drawWave(canvas, color[4], 0.8, 2, 0);
    }
    
    /**
    * 波を描画
    * drawWave(色, 不透明度, 波の幅のzoom, 波の開始位置の遅れ)
    */
    function drawWave(canvas, color, alpha, zoom, delay) {
    	var context = canvas.contextCache;
    	context.strokeStyle = color;//線の色
    	context.lineWidth = 1;//線の幅
    	context.globalAlpha = alpha;
    	context.beginPath(); //パスの開始
    	drawSine(canvas, info.t / 0.5, zoom, delay);
    	context.stroke(); //線
    }
    
    /**
     * Function to draw sine
     * 
     * The sine curve is drawn in 10px segments starting at the origin. 
     * drawSine(時間, 波の幅のzoom, 波の開始位置の遅れ)
     */
    function drawSine(canvas, t, zoom, delay) {
    	var xAxis = Math.floor(canvas.height/2);
    	var yAxis = 0;
    	var context = canvas.contextCache;
    	// Set the initial x and y, starting at 0,0 and translating to the origin on
    	// the canvas.
    	var x = t; //時間を横の位置とする
    	var y = Math.sin(x)/zoom;
    	context.moveTo(yAxis, unit*y+xAxis); //スタート位置にパスを置く
    
    	// Loop to draw segments (横幅の分、波を描画)
    	for (i = yAxis; i <= canvas.width + 10; i += 10) {
    		x = t+(-yAxis+i)/unit/zoom;
    		y = Math.sin(x - delay)/3;
    		context.lineTo(i, unit*y+xAxis);
    	}
    }
    
    init();
    
    投稿日:2022年08月03日
  • 波線(1つ)

    カテゴリー:背景の動き


     

    HTMLの書き方

    head終了タグ直前に自作のCSSを読み込みます。

    <link rel="stylesheet" type="text/css" href="css/5-14.css">

    body内の波を表示させたい場所にHTMLを記載します。

    <canvas id="waveCanvas"></canvas>

    body 終了タグ直前に動きを制御する自作のJS を読み込みます。

    <script src="js/5-14.js"></script>

     

    CSSの書き方

    高さを持たせた親要素の中に設置すると描画されます。
    特定の要素の下部に波を入れたい時は、親要素に配置の基点となるposition:relative;をつけcanvasタグを絶対配置でbottom:0;に指定します。
    (例)

    <div class="wave">
    	<canvas id="waveCanvas"></canvas>
    </div>
    .wave{
    	position:relative;
    	height:200px;/*何も表示されない場合は各波の親要素に高さを持たせましょう。*/
    }
    canvas{
    	position: absolute;
    	bottom: 0;
    	left:0;
    	width: 100%;
    }

     

    JSの書き方

    var unit = 100,
    canvasList, // キャンバスの配列
    info = {}, // 全キャンバス共通の描画情報
    colorList; // 各キャンバスの色情報
    
    /**
     * Init function.
     * 
     * Initialize variables and begin the animation.
     */
    function init() {
    	info.seconds = 0;
    	info.t = 0;
    	canvasList = [ ];
    	colorList = [ ];
    	// canvas1個めの色指定
    	canvasList.push(document.getElementById("waveCanvas"));
    	colorList.push([ '#0ff', '#ff0', '#f00', '#00f', '#f0f' ]);//重ねる波線の色設定
        
    	
    	// 各キャンバスの初期化
    	for(var canvasIndex in canvasList) {
    	var canvas = canvasList[ canvasIndex ];
    	canvas.width = document.documentElement.clientWidth; //Canvasのwidthをウィンドウの幅に合わせる
    	canvas.height = 200;//波の高さ
    	canvas.contextCache = canvas.getContext("2d");
    }
    	// 共通の更新処理呼び出し
    	update();
    }
    
    function update() {
    	for(var canvasIndex in canvasList) {
    		var canvas = canvasList[ canvasIndex ];
    		// 各キャンバスの描画
    		draw(canvas, colorList[ canvasIndex ]);
    	}
    	// 共通の描画情報の更新
    	info.seconds = info.seconds + .014;
    	info.t = info.seconds*Math.PI;
    	// 自身の再起呼び出し
    	setTimeout(update, 35);
    }
    
    /**
     * Draw animation function.
     * 
     * This function draws one frame of the animation, waits 20ms, and then calls
     * itself again.
     */
    function draw(canvas, color) {
    	// 対象のcanvasのコンテキストを取得
    	var context = canvas.contextCache;
    	// キャンバスの描画をクリア
    	context.clearRect(0, 0, canvas.width, canvas.height);
    
    	//波線を描画 drawWave(canvas, color[ 数字(波の数を0から数えて指定) ], 透過, 波の幅のzoom,波の開始位置の遅れ )
    	drawWave(canvas, color[ 0 ], 0.8, 3, 0);
    	drawWave(canvas, color[ 1 ], 0.5, 4, 0);
    	drawWave(canvas, color[ 2 ], 0.3, 1.6, 0);
    	drawWave(canvas, color[ 3 ], 0.2, 3, 100);
    	drawWave(canvas, color[ 4 ], 0.5, 1.6, 250);
    }
    
    /**
    * 波を描画
    * drawWave(色, 不透明度, 波の幅のzoom, 波の開始位置の遅れ)
    */
    function drawWave(canvas, color, alpha, zoom, delay) {
    	var context = canvas.contextCache;
    	context.strokeStyle = color;//線の色
    	context.lineWidth = 1;//線の幅
    	context.globalAlpha = alpha;
    	context.beginPath(); //パスの開始
    	drawSine(canvas, info.t / 0.5, zoom, delay);
    	context.stroke(); //線
    }
    
    /**
     * Function to draw sine
     * 
     * The sine curve is drawn in 10px segments starting at the origin. 
     * drawSine(時間, 波の幅のzoom, 波の開始位置の遅れ)
     */
    function drawSine(canvas, t, zoom, delay) {
    	var xAxis = Math.floor(canvas.height/2);
    	var yAxis = 0;
    	var context = canvas.contextCache;
    	// Set the initial x and y, starting at 0,0 and translating to the origin on
    	// the canvas.
    	var x = t; //時間を横の位置とする
    	var y = Math.sin(x)/zoom;
    	context.moveTo(yAxis, unit*y+xAxis); //スタート位置にパスを置く
    
    	// Loop to draw segments (横幅の分、波を描画)
    	for (i = yAxis; i <= canvas.width + 10; i += 10) {
    		x = t+(-yAxis+i)/unit/zoom;
    		y = Math.sin(x - delay)/3;
    		context.lineTo(i, unit*y+xAxis);
    	}
    }
    
    init();
    投稿日:2022年08月03日
  • 波打つ(複数 重なりあり)

    カテゴリー:背景の動き


     

    HTMLの書き方
    head終了タグ直前に自作のCSSを読み込みます。

    <link rel="stylesheet" type="text/css" href="css/5-13.css">

    body内の波を表示させたい場所にHTMLを記載します。

    <canvas id="waveCanvas"></canvas>
    
    <!--↓波を増やしたい場合は、idを別にしてcanvasタグを追加していく-->
    
    <canvas id="waveCanvas2"></canvas>
    <canvas id="waveCanvas3"></canvas>

    body 終了タグ直前に動きを制御する自作のJS を読み込みます。

    <script src="js/5-13.js"></script>

     

    CSSの書き方
    高さを持たせた親要素の中に設置すると描画されます。
    特定の要素の下部に波を入れたい時は、親要素に配置の基点となるposition:relative;をつけcanvasタグを絶対配置でbottom:0;に指定します。

    (例)

    <div class="wave">
    	<canvas id="waveCanvas"></canvas>
    </div>
    .wave{
    	position:relative;
    	height:200px;/*何も表示されない場合は各波の親要素に高さを持たせましょう。*/
    	background:#fff;/*背景を塗りつぶして重ねた波を表現したい場合は、波を描画する親要素に波と同じ背景色を設定しましょう。*/
    }
    canvas{
    	position: absolute;
    	bottom: 0;
    	left:0;
    	width: 100%;
    }

     

    JSの書き方

    var unit = 100,
    canvasList, // キャンバスの配列
    info = {}, // 全キャンバス共通の描画情報
    colorList; // 各キャンバスの色情報
    
    /**
     * Init function.
     * 
     * Initialize variables and begin the animation.
     */
    function init() {
    	info.seconds = 0;
    	info.t = 0;
    	canvasList = [ ];
    	colorList = [ ];
    	// canvas1個めの色指定
    	canvasList.push(document.getElementById("waveCanvas"));
    	colorList.push([ '#666', '#ccc', '#eee' ]);//重ねる波の色設定
    
    	// canvas2個めの色指定
    	canvasList.push(document.getElementById("waveCanvas2"));
    	colorList.push([ '#43c0e4' ]);
        
    	// canvas3個めの色指定
    	canvasList.push(document.getElementById("waveCanvas3"));
    	colorList.push([ '#fff' ]);
    
    	// 各キャンバスの初期化
    	for(var canvasIndex in canvasList) {
    	var canvas = canvasList[ canvasIndex ];
    	canvas.width = document.documentElement.clientWidth; //Canvasのwidthをウィンドウの幅に合わせる
    	canvas.height = 200;//波の高さ
    	canvas.contextCache = canvas.getContext("2d");
    	}
    	// 共通の更新処理呼び出し
    	update();
    }
    
    function update() {
    	for(var canvasIndex in canvasList) {
    		var canvas = canvasList[ canvasIndex ];
    		// 各キャンバスの描画
    		draw(canvas, colorList[ canvasIndex ]);
    	}
    	// 共通の描画情報の更新
    	info.seconds = info.seconds + .014;
    	info.t = info.seconds*Math.PI;
    	// 自身の再起呼び出し
    	setTimeout(update, 35);
    }
    
    /**
     * Draw animation function.
     * 
     * This function draws one frame of the animation, waits 20ms, and then calls
     * itself again.
     */
    function draw(canvas, color) {
    	// 対象のcanvasのコンテキストを取得
    	var context = canvas.contextCache;
    	// キャンバスの描画をクリア
    	context.clearRect(0, 0, canvas.width, canvas.height);
    	//波の重なりを描画 drawWave(canvas, color[ 数字(波の数を0から数えて指定) ], 透過, 波の幅のzoom,波の開始位置の遅れ )
    	drawWave(canvas, color[ 0 ], 0.5, 3, 0);
    	drawWave(canvas, color[ 1 ], 0.4, 2, 250);
    	drawWave(canvas, color[ 2 ], 0.2, 1.6, 100);
    }
    
    /**
    * 波を描画
    * drawWave(色, 不透明度, 波の幅のzoom, 波の開始位置の遅れ)
    */
    function drawWave(canvas, color, alpha, zoom, delay) {
    	var context = canvas.contextCache;
    	context.fillStyle = color;//塗りの色
    	context.globalAlpha = alpha;
    	context.beginPath(); //パスの開始
    	drawSine(canvas, info.t / 0.5, zoom, delay);
    	context.lineTo(canvas.width + 10, canvas.height); //パスをCanvasの右下へ
    	context.lineTo(0, canvas.height); //パスをCanvasの左下へ
    	context.closePath() //パスを閉じる
    	context.fill(); //塗りつぶす
    }
    
    /**
     * Function to draw sine
     * 
     * The sine curve is drawn in 10px segments starting at the origin. 
     * drawSine(時間, 波の幅のzoom, 波の開始位置の遅れ)
     */
    function drawSine(canvas, t, zoom, delay) {
    	var xAxis = Math.floor(canvas.height/2);
    	var yAxis = 0;
    	var context = canvas.contextCache;
    	// Set the initial x and y, starting at 0,0 and translating to the origin on
    	// the canvas.
    	var x = t; //時間を横の位置とする
    	var y = Math.sin(x)/zoom;
    	context.moveTo(yAxis, unit*y+xAxis); //スタート位置にパスを置く
    
    	// Loop to draw segments (横幅の分、波を描画)
    	for (i = yAxis; i <= canvas.width + 10; i += 10) {
    		x = t+(-yAxis+i)/unit/zoom;
    		y = Math.sin(x - delay)/3;
    		context.lineTo(i, unit*y+xAxis);
    	}
    }
    
    init();
    
    投稿日:2022年08月03日
1 / 41234Next

アーカイブ

  • CSS (117)
    • スクロールダウン (8)
    • テキストナビゲーション (11)
    • ボタン (52)
    • メニュー (1)
    • 動画 (2)
    • 検索 (3)
    • 画像リンクの動き (23)
    • 背景の動き (17)
  • Illustrator (8)
  • JS (93)
    • アコーディオンパネル (2)
    • アニメーション (1)
    • エリアの動き (7)
    • ギャラリー (6)
    • グラフ (7)
    • スライド (9)
    • テキストの動き (17)
    • ニュースティッカー (1)
    • ページトップリンク (9)
    • ページ内リンク (2)
    • メニュー (28)
    • モーダルウィンドウ (1)
    • ローディング (3)
  • Photoshop (1)
  • PHP (20)
  • WordPress (4)
    • プラグイン (2)
    • リンク (1)
  • お客様観覧用 (11)
    • WEB制作プラン (1)
    • アニメーション (8)
    • グローバルナビゲーション (1)
    • スライド (1)
  • サーバー (6)
    • CPI (1)
  • 未分類 (6)
  • 法律 (2)
    • 医療法 (1)
    • 柔道整復師法 (1)
TOP
  • CSS
    • スクロールダウン
    • テキストナビゲーション
    • ボタン
    • メニュー
    • 動画
    • 検索
    • 画像リンクの動き
    • 背景の動き
  • Illustrator
  • JS
    • アコーディオンパネル
    • アニメーション
    • エリアの動き
    • ギャラリー
    • グラフ
    • スライド
    • テキストの動き
    • ニュースティッカー
    • ページトップリンク
    • ページ内リンク
    • メニュー
    • モーダルウィンドウ
    • ローディング
  • Photoshop
  • PHP
  • WordPress
    • プラグイン
    • リンク
  • お客様観覧用
    • WEB制作プラン
    • アニメーション
    • グローバルナビゲーション
    • スライド
  • サーバー
    • CPI
  • 未分類
  • 法律
    • 医療法
    • 柔道整復師法
© 2022 isen-print.