플로팅 광고 방식의 일일 수집 및 구성_자바스크립트 기술
왼쪽 또는 오른쪽에 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 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











JavaScript 문자열 교체 방법 및 FAQ에 대한 자세한 설명 이 기사는 JavaScript에서 문자열 문자를 대체하는 두 가지 방법 인 내부 JavaScript 코드와 웹 페이지의 내부 HTML을 탐색합니다. JavaScript 코드 내부의 문자열을 교체하십시오 가장 직접적인 방법은 대체 () 메소드를 사용하는 것입니다. str = str.replace ( "find", "replace"); 이 메소드는 첫 번째 일치 만 대체합니다. 모든 경기를 교체하려면 정규 표현식을 사용하고 전역 플래그 g를 추가하십시오. str = str.replace (/fi

이 튜토리얼은 사용자 정의 Google 검색 API를 블로그 또는 웹 사이트에 통합하는 방법을 보여 주며 표준 WordPress 테마 검색 기능보다보다 세련된 검색 경험을 제공합니다. 놀랍게도 쉽습니다! 검색을 Y로 제한 할 수 있습니다

그래서 여기 당신은 Ajax라는이 일에 대해 배울 준비가되어 있습니다. 그러나 정확히 무엇입니까? Ajax라는 용어는 역동적이고 대화식 웹 컨텐츠를 만드는 데 사용되는 느슨한 기술 그룹을 나타냅니다. 원래 Jesse J에 의해 만들어진 Ajax라는 용어

이 기사 시리즈는 2017 년 중반에 최신 정보와 새로운 예제로 다시 작성되었습니다. 이 JSON 예에서는 JSON 형식을 사용하여 파일에 간단한 값을 저장하는 방법을 살펴 봅니다. 키 값 쌍 표기법을 사용하여 모든 종류를 저장할 수 있습니다.

손쉬운 웹 페이지 레이아웃에 대한 jQuery 활용 : 8 에센셜 플러그인 jQuery는 웹 페이지 레이아웃을 크게 단순화합니다. 이 기사는 프로세스를 간소화하는 8 개의 강력한 JQuery 플러그인을 강조합니다. 특히 수동 웹 사이트 생성에 유용합니다.

핵심 포인트 JavaScript에서는 일반적으로 메소드를 "소유"하는 객체를 말하지만 함수가 호출되는 방식에 따라 다릅니다. 현재 객체가 없으면 글로벌 객체를 나타냅니다. 웹 브라우저에서는 창으로 표시됩니다. 함수를 호출 할 때 이것은 전역 객체를 유지하지만 객체 생성자 또는 그 메소드를 호출 할 때는 객체의 인스턴스를 나타냅니다. call (), apply () 및 bind ()와 같은 메소드를 사용 하여이 컨텍스트를 변경할 수 있습니다. 이 방법은 주어진이 값과 매개 변수를 사용하여 함수를 호출합니다. JavaScript는 훌륭한 프로그래밍 언어입니다. 몇 년 전,이 문장은있었습니다

JQuery는 훌륭한 JavaScript 프레임 워크입니다. 그러나 어떤 도서관과 마찬가지로, 때로는 진행 상황을 발견하기 위해 후드 아래로 들어가야합니다. 아마도 버그를 추적하거나 jQuery가 특정 UI를 달성하는 방법에 대해 궁금한 점이 있기 때문일 것입니다.

이 게시물은 Android, BlackBerry 및 iPhone 앱 개발을위한 유용한 치트 시트, 참조 안내서, 빠른 레시피 및 코드 스 니펫을 컴파일합니다. 개발자가 없어서는 안됩니다! 터치 제스처 참조 안내서 (PDF) Desig를위한 귀중한 자원
