フローティング広告手法の毎日の収集と整理_JavaScript スキル
1 左側または右側のフローティング広告。
CSS スタイル:
*{padding: 0;margin: 0;} .fl{float:left;display: inline;} .fr{float: right;display: inline;} .clearfix{*zoom: 1;} .clearfix:after{ display: block; content: ""; height: 0;line-height: 0;visibility: hidden; clear: both;} /*tab 切换*/ .tab_title{ line-height: 30px; border-bottom: 1px solid #ccc; width: 360px;margin: 0 auto;} .tab_title a{ display: inline-block; font-size: 16px;color: #333; text-decoration: none; margin-right: 20px;} .tab_title a.active{color: red;} .tab_content{width: 340px; padding:5px 10px;margin: 0 auto; border: 1px solid #ccc; height: 120px;} /*文字滚动*/ .moveScroll{ width: 360px; height: 120px; border: 1px solid #ccc; margin: 50px auto;} .moveparent{ width: 330px;height: 90px;overflow: hidden; margin:15px auto;} .moveScroll .content{ color: #333; } /*文本输入框*/ .inputText{ width: 320px; padding:10px; line-height: 22px;margin: 10px auto;display: block;color: #999;} /*幻灯片*/ .wrapper { width: 324px; height: 325px; _height: 321px; position: relative; z-index: 1; margin: 20PX auto; } .wrapper .main { width: 324px; height: 222px; overflow: hidden; } .wrapper li { float: left; display: inline; } .wrapper ul img { width: 324px; height: 222px; position: relative; z-index: 1; } .wrapper ul span { position: absolute; display: block; text-align: center; width: 324px; height: 20px; overflow: hidden; bottom: 10px; left: 0; } .wrapper ol { margin-right: -4px; height: 58px; *zoom: 1; } .wrapper ol:after { display: block; content: ""; line-height: 0; height: 0; visibility: hidden; clear: both; } .wrapper ol img { width: 78px; height: 52px; margin: 6px 4px 0 0; } .wrapper ol li { opacity: 0.5; filter: alpha(opacity=50); cursor: pointer; } .wrapper ol .active { opacity: 1; filter: alpha(opacity=100); }
html コード:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>简jQuery左右对称浮动广告代码</title> <link rel="stylesheet" href="css/style.css" /> </head> <body> <div style="height:2000px;"></div> <!-- 代码部分begin --> <div id="floatright" style="position: absolute; z-index: 10; "></div> <script src="js/jquery.js" ></script> <script src="js/floatAd.js" ></script> <script> window.onload = function(){ var ad2 = new FloatAd({ nodeLink : "<a href='广告连接地址'><img src='广告图片' border=0 /></a>" , floatObj : "floatleft", x : 10, y : 400, locate : "left" }); ad2.play(); } </script> <!-- 代码部分end --> </body> </html>
jquery の紹介に加えて (jquery とは何かと聞きたい場合は、外に出て左に曲がってください)、js ファイルには次のものも必要です。
var FloatAd = function(obj){ var mainNode = $("." + obj.main)[0]; if(obj.nodeLink && (typeof obj.nodeLink == "string")){ var newFloatObj = document.createElement("div"); newFloatObj.id = obj.floatObj; newFloatObj.style.position = "absolute"; newFloatObj.style.zIndex = 10; newFloatObj.innerHTML = obj.nodeLink; document.body.appendChild(newFloatObj); } this.ad = document.getElementById(obj.floatObj); this.main = document.getElementById(obj.main)||mainNode; this.x = obj.x; this.y = obj.y; this.locate = obj.locate; this.space = obj.space; var that = this; this.play = function(){ setInterval(function(){ that.calculate(); },10); }; } FloatAd.prototype = { constructor : FloatAd, calculate : function(){ var obj_x = this.x, obj_y = this.y, main_offsetLeft = document.documentElement.scrollLeft||document.body.scrollLeft, main_offsetTop = document.documentElement.scrollTop||document.body.scrollTop; if(this.main){ if(this.locate == "left"){ obj_x = this.main.offsetLeft - this.ad.offsetWidth - this.space; }else if(this.locate == "right"){ obj_x = this.main.offsetLeft + this.main.offsetWidth + this.space; } if(this.ad.offsetLeft != main_offsetLeft + obj_x){ var dx = (main_offsetLeft + obj_x - this.ad.offsetLeft)*0.08; dx = (dx > 0 ? 1 : -1)*Math.ceil(Math.abs(dx)); this.ad.style.left = this.ad.offsetLeft + dx + "px"; } }else{ if(this.locate == "left"){ this.ad.style.left = obj_x + "px"; }else if(this.locate == "right"){ this.ad.style.right = obj_x +"px"; } } if(this.ad.offsetTop != main_offsetTop + obj_y){ var dy = (main_offsetTop + obj_y - this.ad.offsetTop)*0.08; dy = (dy > 0 ? 1 : -1)*Math.ceil(Math.abs(dy)); this.ad.style.top = this.ad.offsetTop + dy + "px"; } } }
これは、私がこのエフェクトを使用したときにまとめたもので、オンラインで事例をコピーし、みんなの便宜のために整理しました。
2 全画面フローティングケース: 出窓!
css ファイル:
#img1{ z-index: 100; left: 2px; width: 59px; position: absolute; top: 43px; height: 61px; visibility: visible; }
html ファイル
<html> <head> <title>漂浮广告</title> </head> <link rel="stylesheet" href="floatImg.css"/> <body> <div id=img1> <a href="广告链接地址" target="_blank"> <img src="广告图片"> </a> </div> </body> <script src="链接js"></script> </html>
js コード:
var xPos = 300; var yPos = 200; var step = 1; var delay = 30; var height = 0; var Hoffset = 0; var Woffset = 0; var yon = 0; var xon = 0; var pause = true; var interval; img1.style.top = yPos; function changePos() { width = document.body.clientWidth; height = document.body.clientHeight; Hoffset = img1.offsetHeight; Woffset = img1.offsetWidth; img1.style.left = xPos + document.body.scrollLeft; img1.style.top = yPos + document.body.scrollTop; if (yon) {yPos = yPos + step;} else {yPos = yPos - step;} if (yPos < 0) {yon = 1;yPos = 0;} if (yPos >= (height - Hoffset)) {yon = 0;yPos = (height - Hoffset);} if (xon) {xPos = xPos + step;} else {xPos = xPos - step;} if (xPos < 0) {xon = 1;xPos = 0;} if (xPos >= (width - Woffset)) {xon = 0;xPos = (width - Woffset); } } function start() { img1.visibility = "visible"; interval = setInterval('changePos()', delay); } function pause_resume() { if(pause) { clearInterval(interval); pause = false;} else { interval = setInterval('changePos()',delay); pause = true; } } start();
上記の内容は編集者が皆様に向けてまとめたフローティング広告手法ですので、皆様のお役に立てれば幸いです。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









フロントエンドのサーマルペーパーチケット印刷のためのよくある質問とソリューションフロントエンド開発におけるチケット印刷は、一般的な要件です。しかし、多くの開発者が実装しています...

スキルや業界のニーズに応じて、PythonおよびJavaScript開発者には絶対的な給与はありません。 1. Pythonは、データサイエンスと機械学習でさらに支払われる場合があります。 2。JavaScriptは、フロントエンドとフルスタックの開発に大きな需要があり、その給与もかなりです。 3。影響要因には、経験、地理的位置、会社の規模、特定のスキルが含まれます。

JavaScriptは現代のWeb開発の基礎であり、その主な機能には、イベント駆動型のプログラミング、動的コンテンツ生成、非同期プログラミングが含まれます。 1)イベント駆動型プログラミングにより、Webページはユーザー操作に応じて動的に変更できます。 2)動的コンテンツ生成により、条件に応じてページコンテンツを調整できます。 3)非同期プログラミングにより、ユーザーインターフェイスがブロックされないようにします。 JavaScriptは、Webインタラクション、シングルページアプリケーション、サーバー側の開発で広く使用されており、ユーザーエクスペリエンスとクロスプラットフォーム開発の柔軟性を大幅に改善しています。

同じIDを持つ配列要素をJavaScriptの1つのオブジェクトにマージする方法は?データを処理するとき、私たちはしばしば同じIDを持つ必要性に遭遇します...

Console.log出力の違いの根本原因に関する詳細な議論。この記事では、Console.log関数の出力結果の違いをコードの一部で分析し、その背後にある理由を説明します。 �...

この記事の視差スクロールと要素のアニメーション効果の実現に関する議論では、Shiseidoの公式ウェブサイト(https://www.shisido.co.co.jp/sb/wonderland/)と同様の達成方法について説明します。

JavaScriptを学ぶことは難しくありませんが、挑戦的です。 1)変数、データ型、関数などの基本概念を理解します。2)非同期プログラミングをマスターし、イベントループを通じて実装します。 3)DOM操作を使用し、非同期リクエストを処理することを約束します。 4)一般的な間違いを避け、デバッグテクニックを使用します。 5)パフォーマンスを最適化し、ベストプラクティスに従ってください。

フロントエンドのVSCodeと同様に、パネルドラッグアンドドロップ調整機能の実装を調べます。フロントエンド開発では、VSCODEと同様のVSCODEを実装する方法...
