この記事では、JavaScript に関する関連知識をお届けします。主に、簡単な CSS と JS を使用して初心者指導効果を実現する方法を紹介します。興味のある友人は以下を参照してください。皆さんのお役に立てれば幸いです。
ナンセンスの始まり: 初心者指導効果を達成するための簡単な CSS と JS を通して
# 1. 効果を実現するには
# 2. 実現するには
#実装は実際には非常に簡単です。mask このバージョンでは、画面全体 div をタイル表示し、背景色を透明 transparent に設定し、outline を半透明に設定します。次に、同様に arrow と warning ラベルを作成します。
1. 使用法
let maskIntroduceManage = new MaskIntroduceManage([ new MaskIntroduceItem('one','人生若只如初见'), new MaskIntroduceItem('two','何事秋风悲画扇'), new MaskIntroduceItem('five','等闲却变故人心'), new MaskIntroduceItem('six','骊山语罢清宵半'), new MaskIntroduceItem('four','却道故人心易变'), new MaskIntroduceItem('finally','谢谢大家支持!') ]) maskIntroduceManage.benginIntroduce()
2. HTML
nbsp;html> <meta> <style> *{ padding: 0; margin: 0; } .content { padding: 0; display: flex; flex-direction: row; justify-content: space-between; align-items: center; width: 100%; } span { width: 60px; height: 60px; line-height: 60px; margin-left: 40px; margin-top: 140px; margin-bottom: 0px; text-align: center; display: block; background-color: antiquewhite; } .finally { width: 100px; height: 100px; background-color: cornsilk; border-radius: 50%; line-height: 100px; text-align: center; margin-top: 30px; margin-left: auto; margin-right: auto; } span:nth-of-type(1){ margin-top: 30px; } span:nth-of-type(2){ margin-top: 70px; } span:nth-of-type(3){ margin-top: 160px; } span:nth-of-type(4){ margin-top: 160px; } span:nth-of-type(5){ margin-top: 70px; } span:nth-of-type(6){ margin-top: 30px; } </style> <div> <span>纳</span> <span>兰</span> <span>容</span> <span>若</span> <span>作</span> <span>词</span> </div> <div> 谢谢 </div> <script></script> <script> let maskIntroduceManage = new MaskIntroduceManage([ new MaskIntroduceItem('one','人生若只如初见'), new MaskIntroduceItem('two','何事秋风悲画扇'), new MaskIntroduceItem('five','等闲却变故人心'), new MaskIntroduceItem('six','骊山语罢清宵半'), new MaskIntroduceItem('four','却道故人心易变'), new MaskIntroduceItem('finally','谢谢大家支持!') ]) maskIntroduceManage.benginIntroduce() </script>
3.JS
// 单元信息model class MaskIntroduceItem { // 需要引导的dom的ID id // 需要引导的dom功能描述 warming constructor(id,warming){ this.id = id this.warming = warming } } // 遮罩操作类 class MaskIntroduceManage { // 消息展示类集合 maskIntroduceItems // 遮罩层 el // 遮罩层提示框 warmingEl // 指引肩头 guidanceEl // 展示的第几个 currentShowIndex = 0 // 记录window事件 windowEvent = null constructor(maskIntroduceItems){ this.maskIntroduceItems = maskIntroduceItems } // 添加消息展示类 addIntroduceItem(introduceItem){ this.maskIntroduceItems.push(introduceItem) } // body增加遮罩 addMaskToBody(){ //添加遮罩框 this.el = document.createElement('div') this.el.style.cssText = 'position: fixed;background: transparent;outline:rgba(0, 0, 0, 0.5) 3500px solid;' let body = document.getElementsByTagName('body')[0] body.appendChild(this.el) //添加提示框 this.warmingEl = document.createElement('div') this.warmingEl.style.cssText = 'position:fixed;width:100px;background:white;border-radius: 10px;padding: 30px;font-size: 14px;' body.appendChild(this.warmingEl) //添加指引箭头 this.guidanceEl = document.createElement('div') this.guidanceEl.style.cssText = 'position:fixed;width: 14px; height: 13px; background-color: white;clip-path: polygon(50% 0,100% 100%,0 100%);' body.appendChild(this.guidanceEl) //设置body禁止滚动 body.style.overflow = 'hidden' //保留window事件 if(window.onclick){ this.windowEvent = window.onclick } window.onclick = ()=>{ this.nextIntroduce() } } // 开始引导 benginIntroduce(){ this.addMaskToBody() this.nextIntroduce() } // 下一步 nextIntroduce(){ let maskIntroduceItem = this.maskIntroduceItems.length > 0 ? this.maskIntroduceItems[this.currentShowIndex] : null if(!maskIntroduceItem){ return } let needIntroduceEl = document.getElementById(maskIntroduceItem.id) //遮罩层的镂空位置 this.el.style.width = needIntroduceEl.offsetWidth + 'px' this.el.style.height = needIntroduceEl.offsetHeight + 'px' this.el.style.top = this.getElementPosition(needIntroduceEl).top + 'px' this.el.style.left = this.getElementPosition(needIntroduceEl).left + 'px' //设置对应倒角,但是由于背景颜色是透明的,所以,没有效果(???) //this.el.style.borderRadius = window.getComputedStyle(needIntroduceEl,null)['border-radius'] this.currentShowIndex ++ //指引箭头位置 let guidanceElLeft = this.getElementPosition(needIntroduceEl).left + needIntroduceEl.offsetWidth / 2.0 this.guidanceEl.style.top = this.getElementPosition(needIntroduceEl).top + needIntroduceEl.offsetHeight + 20 + 'px' this.guidanceEl.style.left = guidanceElLeft + 'px' //提示框的位置 this.warmingEl.style.top = this.getElementPosition(this.guidanceEl).top + this.guidanceEl.offsetHeight - 4 + 'px' let warmingElLeft = this.getElementPosition(needIntroduceEl).left - ((this.warmingEl.offsetWidth - needIntroduceEl.offsetWidth) / 2.0) if(warmingElLeft document.getElementsByTagName('body')[0].offsetWidth){ warmingElLeft = warmingElLeft - 10 - (this.warmingEl.offsetWidth - needIntroduceEl.offsetWidth) / 2.0 } this.warmingEl.style.left = warmingElLeft + 'px' this.warmingEl.innerHTML = maskIntroduceItem.warming //最后一个展示完恢复window点击事件 if(this.currentShowIndex >= this.maskIntroduceItems.length){ setTimeout(() => { //移除当前遮罩 this.el.remove() //移除当前提示框 this.warmingEl.remove() //移除箭头 this.guidanceEl.remove() //设置body可以滚动 document.getElementsByTagName('body')[0].style.overflow = 'auto' //恢复window事件 if(this.windowEvent){ window.onclick = this.windowEvent } }, 2000); } } // 获取元素在屏幕的位置 getElementPosition(element){ var top = element.offsetTop var left = element.offsetLeft var currentParent = element.offsetParent; while (currentParent !== null) { top += currentParent.offsetTop left += currentParent.offsetLeft currentParent = currentParent.offsetParent } return {top,left} } }
3. 概要と感想
実装原理は非常にシンプルで、複雑なロジックはあまりありません。現在の「導入が必要です」を渡したいと思います。 " タグ borderRadius を使用して中空部分の面取り値を設定しますが、背景色が透明なので、設定は有効になりますが、効果はありません。コードはぎこちないので、マスターを笑わないでください~
推奨学習: 「JavaScript ビデオ チュートリアル 」
以上がJS+CSSで初心者指導効果を素早く実現の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

PythonとJavaScriptの主な違いは、タイプシステムとアプリケーションシナリオです。 1。Pythonは、科学的コンピューティングとデータ分析に適した動的タイプを使用します。 2。JavaScriptは弱いタイプを採用し、フロントエンドとフルスタックの開発で広く使用されています。この2つは、非同期プログラミングとパフォーマンスの最適化に独自の利点があり、選択する際にプロジェクトの要件に従って決定する必要があります。

PythonまたはJavaScriptを選択するかどうかは、プロジェクトの種類によって異なります。1)データサイエンスおよび自動化タスクのPythonを選択します。 2)フロントエンドとフルスタック開発のためにJavaScriptを選択します。 Pythonは、データ処理と自動化における強力なライブラリに好まれていますが、JavaScriptはWebインタラクションとフルスタック開発の利点に不可欠です。

PythonとJavaScriptにはそれぞれ独自の利点があり、選択はプロジェクトのニーズと個人的な好みに依存します。 1. Pythonは、データサイエンスやバックエンド開発に適した簡潔な構文を備えた学習が簡単ですが、実行速度が遅くなっています。 2。JavaScriptはフロントエンド開発のいたるところにあり、強力な非同期プログラミング機能を備えています。 node.jsはフルスタックの開発に適していますが、構文は複雑でエラーが発生しやすい場合があります。

javascriptisnotbuiltoncorc;それは、解釈されていることを解釈しました。

JavaScriptは、フロントエンドおよびバックエンド開発に使用できます。フロントエンドは、DOM操作を介してユーザーエクスペリエンスを強化し、バックエンドはnode.jsを介してサーバータスクを処理することを処理します。 1.フロントエンドの例:Webページテキストのコンテンツを変更します。 2。バックエンドの例:node.jsサーバーを作成します。

PythonまたはJavaScriptの選択は、キャリア開発、学習曲線、エコシステムに基づいている必要があります。1)キャリア開発:Pythonはデータサイエンスとバックエンド開発に適していますが、JavaScriptはフロントエンドおよびフルスタック開発に適しています。 2)学習曲線:Python構文は簡潔で初心者に適しています。 JavaScriptの構文は柔軟です。 3)エコシステム:Pythonには豊富な科学コンピューティングライブラリがあり、JavaScriptには強力なフロントエンドフレームワークがあります。

JavaScriptフレームワークのパワーは、開発を簡素化し、ユーザーエクスペリエンスとアプリケーションのパフォーマンスを向上させることにあります。フレームワークを選択するときは、次のことを検討してください。1。プロジェクトのサイズと複雑さ、2。チームエクスペリエンス、3。エコシステムとコミュニティサポート。

はじめに私はあなたがそれを奇妙に思うかもしれないことを知っています、JavaScript、C、およびブラウザは正確に何をしなければなりませんか?彼らは無関係であるように見えますが、実際、彼らは現代のウェブ開発において非常に重要な役割を果たしています。今日は、これら3つの間の密接なつながりについて説明します。この記事を通して、JavaScriptがブラウザでどのように実行されるか、ブラウザエンジンでのCの役割、およびそれらが協力してWebページのレンダリングと相互作用を駆動する方法を学びます。私たちは皆、JavaScriptとブラウザの関係を知っています。 JavaScriptは、フロントエンド開発のコア言語です。ブラウザで直接実行され、Webページが鮮明で興味深いものになります。なぜJavascrを疑問に思ったことがありますか


ホットAIツール

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

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

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

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

人気の記事

ホットツール

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

SublimeText3 Linux 新バージョン
SublimeText3 Linux 最新バージョン

WebStorm Mac版
便利なJavaScript開発ツール

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境
