国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

ホームページ ウェブフロントエンド jsチュートリアル HTML CSS および JavaScript コードでのアラートとカスタム アラート

HTML CSS および JavaScript コードでのアラートとカスタム アラート

Oct 31, 2024 am 09:31 AM

Alert Vs Custom Alert in html css and javascript code

HTMLコード

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Custom Alert Box</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="button-container">
        <!-- Button to Trigger Default Alert -->
        <button class="btn default-alert-btn">Default Alert</button>

        <!-- Button to Trigger Custom Alert -->
        <button class="btn custom-alert-btn">Custom Alert</button>
    </div>

    <!-- Custom Alert Box -->
    <div class="custom-alert" id="customAlert">
        <h1>Warning</h1>
        <span class="alert-text">This is a custom alert with a close
             option and animated border!</span>
        <button class="close-btn">&times;</button>
    </div>

    <script src="script.js"></script>
</body>
</html>

CSSコード

/* Reset */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-color: #1a1a1a;
  font-family: Arial, sans-serif;
  color: #fff;
}
/* Button Styling */
.button-container {
  display: flex;
  gap: 20px;
}
.btn {
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 0.2s;
}

.default-alert-btn {
  background-color: #4285f4;
  color: white;
}

.custom-alert-btn {
  background-color: #ff5722;
  color: white;
}

.btn:hover {
  transform: scale(1.05);
}

.custom-alert {
  position: fixed;
  top: 50px;
  /* left: 50%; */
  width: 400px;
  padding: 5px;

  background-color: #333;
  color: #fff;
  border-radius: 10px;
  display: none;
  opacity: 0;
  transform: translateX(-50%);
  animation: fadeIn 0.5s forwards;
  /* Animated border effect */
  border: 1px solid transparent;
  border-radius: 10px;
  background-image: linear-gradient(#333, #333),
    linear-gradient(45deg, #ff5722, #4285f4, #0f9d58, #f4b400);
  background-origin: border-box;
  background-clip: content-box, border-box;
  box-shadow: 0px 0px 2px rgba(255, 255, 255, 0.1);
}

/* Multicolored border animation */
@keyframes borderAnimation {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 100% 50%;
  }
}

.custom-alert {
  animation: fadeIn 0.5s forwards, borderAnimation 3s linear infinite;
  background-size: 200% 200%;
}

/* Fade-in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-text {
  display: inline;
}

.close-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #ff5722;
}


ジャバスクリプトコード

// Buttons
const defaultAlertBtn = document.querySelector('.default-alert-btn');
const customAlertBtn = document.querySelector('.custom-alert-btn');
const customAlert = document.getElementById('customAlert');
const closeBtn = document.querySelector('.close-btn');

// Show Default Alert
defaultAlertBtn.addEventListener('click', () => {
    alert("This is the default alert.");
});

// Show Custom Alert
customAlertBtn.addEventListener('click', () => {
    customAlert.style.display = 'block';
    setTimeout(() => {
        customAlert.style.opacity = '1';
    }, 10); // Delay for CSS fade-in effect
});

// Close Custom Alert
closeBtn.addEventListener('click', () => {
    customAlert.style.opacity = '0';
    setTimeout(() => {
        customAlert.style.display = 'none';
    }, 500); // Delay for CSS fade-out effect
});

以上がHTML CSS および JavaScript コードでのアラートとカスタム アラートの詳細內(nèi)容です。詳細については、PHP 中國語 Web サイトの他の関連記事を參照してください。

このウェブサイトの聲明
この記事の內(nèi)容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰屬します。このサイトは、それに相當する法的責任を負いません。盜作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡(luò)ください。

ホットAIツール

Undress AI Tool

Undress AI Tool

脫衣畫像を無料で

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード寫真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

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

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

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

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中國語版

SublimeText3 中國語版

中國語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統(tǒng)合開発環(huán)境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

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

JavaScript vs. Java:どの言語を?qū)Wぶべきですか? JavaScript vs. Java:どの言語を?qū)Wぶべきですか? Jun 10, 2025 am 12:05 AM

JavaScriptisidealforwebdevelopment,whileJavasuitslarge-scaleapplicationsandAndroiddevelopment.1)JavaScriptexcelsincreatinginteractivewebexperiencesandfull-stackdevelopmentwithNode.js.2)Javaisrobustforenterprisesoftwareandbackendsystems,offeringstrong

JavaScriptで使用するコメントシンボル:明確な説明 JavaScriptで使用するコメントシンボル:明確な説明 Jun 12, 2025 am 10:27 AM

JavaScriptでは、シングルラインコメント(//)またはマルチラインコメント(//)を選択することは、コメントの目的とプロジェクトの要件に依存します。 2。詳細なドキュメントには、マルチラインコメントを使用します。 3。コメントスタイルの一貫性を維持します。 4。過剰な承認を避けます。 5.コメントがコードと同期して更新されていることを確認してください。適切な注釈スタイルを選択すると、コードの読みやすさと保守性を向上させることができます。

JavaScriptの究極のガイドコメント:コードの明確さを強化します JavaScriptの究極のガイドコメント:コードの明確さを強化します Jun 11, 2025 am 12:04 AM

はい、javascriptcommentsは不必要に使用されています。

Java vs. JavaScript:混亂を解消します Java vs. JavaScript:混亂を解消します Jun 20, 2025 am 12:27 AM

JavaとJavaScriptは異なるプログラミング言語であり、それぞれ異なるアプリケーションシナリオに適しています。 Javaは大規(guī)模なエンタープライズおよびモバイルアプリケーション開発に使用されますが、JavaScriptは主にWebページ開発に使用されます。

JavaScriptコメント:短い説明 JavaScriptコメント:短い説明 Jun 19, 2025 am 12:40 AM

JavaScriptcommentsEareEssentialential-formaining、およびGuidingCodeexecution.1)single-linecommentseared forquickexplanations.2)多LinecommentsexplaincomplexlogiCorprovidededocumentation.3)clarifyspartsofcode.bestpractic

JavaScriptのマスターコメント:包括的なガイド JavaScriptのマスターコメント:包括的なガイド Jun 14, 2025 am 12:11 AM

ContureCrucialInjavascript formantaining andFosteringCollaboration.1)TheypindeBugging、Onboarding、およびUnderstandingCodeevolution.2)usesingle-linecomments for quickexplanations andmulti-linecomments fordeTeTaileddespransions.3)BestPractsinclud

JavaScriptデータ型:ディープダイビング JavaScriptデータ型:ディープダイビング Jun 13, 2025 am 12:10 AM

javascripthasseveralprimitivedatypes:number、string、boolean、undefined、null、symbol、andbigint、andnon-primitiveTypeslike objectandarray

JavaScript vs. Java:開発者向けの包括的な比較 JavaScript vs. Java:開発者向けの包括的な比較 Jun 20, 2025 am 12:21 AM

javascriptispreferredforwebdevelopment、whilejavaisbetterforlge-scalebackendsystemsandroidapps.1)javascriptexcelsininintingtivewebexperiences withitsdynAmicnature anddommanipulation.2)javaofferstruntypyping-dobject-reientedpeatures

See all articles