Мы используем cookies

все гайды

Гайд по алерт сообщениям

Задача
В данном уроке рассматривается создание информационных сообщений при выполнении каких то действий в веб приложении, используя css и html.
HTML
<!DOCTYPE html>
<html lang="ENG">
<head>
    <meta charset="UTF-8">
    <title>Alerts</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Click on the close button to close the alert message.</h2>
<div class="container">
    <div class="alert-danger">
        <span class="close-btn" onclick="this.parentElement.style.display='none';">&times;</span>
        <strong>Danger!</strong> Indicates a dangerous or potentially negative action.
    </div>
    <div class="alert-success">
        <span class="close-btn" onclick="this.parentElement.style.display='none';">&times;</span>
        <strong>Success!</strong> Indicates a successful or positive action.
    </div>
    <div class="alert-info">
        <span class="close-btn" onclick="this.parentElement.style.display='none';">&times;</span>
        <strong>Info!</strong> Indicates a neutral informative change or action.
    </div>
    <div class="alert-warning">
        <span class="close-btn" onclick="this.parentElement.style.display='none';">&times;</span>
        <strong>Warning!</strong> Indicates a warning that might need attention.
    </div>
</div>
</body>
</html>
CSS
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap');

body {
    font-family: 'Inter', sans-serif;
    text-align: center;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.container {
    max-width: 700px;
    width: 100%;
}

.alert-danger {
    padding: 20px;
    background-color: #f44336;
    color: white;
    margin-bottom: 15px;
    border-radius: 8px;
}

.alert-success {
    padding: 20px;
    background-color: #2FB886;
    color: white;
    margin-bottom: 15px;
    border-radius: 8px;
}

.alert-info {
    padding: 20px;
    background-color: #47A8F5;
    color: white;
    margin-bottom: 15px;
    border-radius: 8px;
}

.alert-warning {
    padding: 20px;
    background-color: #FFA92B;
    color: white;
    margin-bottom: 15px;
    border-radius: 8px;
}

.close-btn {
    margin-left: 15px;
    color: white;
    font-weight: bold;
    float: right;
    font-size: 22px;
    line-height: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.close-btn:hover {
    color: black;
}

Есть идеи?
Pасскажите нам о них

hello@it-justice.com
Privacy policyTerms & conditions
Behance
Вконтакте
Dribble
Linkedin
Goodfirms
©2025. ООО Джастис-ИТ. Все права защищены.