Dark CSS

Responsive Love Toggle Button in Html CSS

Facebook
Twitter
WhatsApp

Project preview

Html code

				
					<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive Toggle Love Button</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
</head>

<body>

    <div class="button-container">
        <div class="button">
            I <span>Love</span> <i class="fas fa-heart"></i> You
        </div>
    </div>

</body>

</html>
				
			

css code

				
					 * {
     padding: 0;
     margin: 0;
     box-sizing: border-box;
     font-family: monospace;
 }

 
body {
     display: flex;
     height: 100vh;
     justify-content: center;
     align-items: center;
     background: #ff9d9dce;
 }

 .button-container {
     padding: 10px 20px;
     width: 12rem;
     min-width: 6rem;
     font-size: 16px;
     border-radius: 5px;
     resize: horizontal;
     overflow: hidden;
     container-type: inline-size;
     container-name: btn;
     display: flex;
     justify-content: center;
     align-items: center;
     gap: 5px;
     white-space: nowrap;
     background: #212121;
     color: #fff;
 }

 .button span { 
     color: #ff2828;
 }

 .button i {
     display: none;
     color: #ff2828;
     font-size: 16px;
 }

 @container btn (max-width: 7rem) {
     .button span {
         display: none;
         opacity: 0;
     }

     .button i {
         display: inline-block;
         opacity: 1;
     }
 }