Pop up for Show informatation
Loading
Pop up for Show informatation
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shubham SidnaleRank #968 · 2.1K reputationPosted Mar 30, 2025, 6:18 AM EDT
Using a Popup in ASP.NET MVC / Blazor
For web applications in ASP.NET MVC or Blazor, popups are typically created using JavaScript modals like Bootstrap Modals.
Example (ASP.NET MVC with Bootstrap):
Sangeetha SRank #212 · 11.4K reputationPosted Apr 1, 2025, 12:20 AM EDT
PopUpComponent.razor:
MainPage.razor:
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 1, 2025, 2:43 AM EDT
To create a pop-up in HTML that displays information when triggered (e.g., by clicking a button), you can use a combination of HTML , CSS , and JavaScript . Below is an example of how to implement this:
Pop-up Example /* Background overlay */ .overlay { display: none; /* Hidden by default */ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */ z-index: 1000; } /* Pop-up box */ .popup { display: none; /* Hidden by default */ position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); z-index: 1001; max-width: 400px; text-align: center; } /* Close button */ .close-btn { float: right; cursor: pointer; font-size: 20px; color: red; } /* Show elements when active */ .active { display: block; } Show Information × Information This is the information displayed in the pop-up box. You can customize it as needed! // Get references to the elements const openPopupBtn = document.getElementById('openPopup'); const closePopupBtn = document.getElementById('closePopup'); const overlay = document.getElementById('overlay'); const popup = document.getElementById('popup'); // Function to open the pop-up openPopupBtn.addEventListener('click', () => { overlay.classList.add('active'); popup.classList.add('active'); }); // Function to close the pop-up closePopupBtn.addEventListener('click', () => { overlay.classList.remove('active'); popup.classList.remove('active'); }); // Close the pop-up if the user clicks outside of it overlay.addEventListener('click', () => { overlay.classList.remove('active'); popup.classList.remove('active'); });HTML Structure :
#openPopup) triggers the pop-up..overlaydiv creates a semi-transparent background behind the pop-up..popupdiv contains the actual content of the pop-up.CSS Styling :
.overlayand.popupare hidden by default (display: none).activeclass is added, they become visible (display: block)..popupis centered usingposition: fixed,top: 50%,left: 50%, andtransform: translate(-50%, -50%).JavaScript Logic :
activeclass to both.overlayand.popup.×) or clicking outside the pop-up removes theactiveclass, hiding the pop-up.Tuhin PaulRank #7 · 71.9K reputationPosted Apr 1, 2025, 2:45 AM EDT
The design uses darker colors for the overlay and pop-up box, along with light text for better contrast.
Dark Theme Pop-up /* Background overlay */ .overlay { display: none; /* Hidden by default */ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9); /* Dark semi-transparent background */ z-index: 1000; } /* Pop-up box */ .popup { display: none; /* Hidden by default */ position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #1e1e1e; /* Dark background */ color: #ffffff; /* Light text */ padding: 20px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3); z-index: 1001; max-width: 400px; text-align: center; } /* Close button */ .close-btn { float: right; cursor: pointer; font-size: 20px; color: #ff4d4d; /* Red close button */ } /* Show elements when active */ .active { display: block; } /* Styling for buttons */ button { background-color: #333333; /* Dark button background */ color: #ffffff; /* Light text */ border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #555555; /* Slightly lighter on hover */ } Show Information × Information This is the information displayed in the dark-themed pop-up box. You can customize it as needed! // Get references to the elements const openPopupBtn = document.getElementById('openPopup'); const closePopupBtn = document.getElementById('closePopup'); const overlay = document.getElementById('overlay'); const popup = document.getElementById('popup'); // Function to open the pop-up openPopupBtn.addEventListener('click', () => { overlay.classList.add('active'); popup.classList.add('active'); }); // Function to close the pop-up closePopupBtn.addEventListener('click', () => { overlay.classList.remove('active'); popup.classList.remove('active'); }); // Close the pop-up if the user clicks outside of it overlay.addEventListener('click', () => { overlay.classList.remove('active'); popup.classList.remove('active'); });Dark Overlay :
.overlayhas a very dark background (rgba(0, 0, 0, 0.9)) to create a moody, immersive effect.Dark Pop-up Box :
.popuphas a dark background (#1e1e1e) and light text (#ffffff) for high contrast.#ff4d4d) to make it stand out.Button Styling :
#333333) with light text (#ffffff) to match the theme.#555555).JavaScript Logic :
activeclass for showing/hiding the pop-up.Tuhin PaulRank #7 · 71.9K reputationPosted Apr 1, 2025, 2:49 AM EDT
An example of a pop-up with a Metro UI theme . Metro UI is known for its clean, minimalistic design, flat colors, and emphasis on typography.
Metro UI Pop-up /* General Reset */ body { margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Metro UI font */ background-color: #f4f4f4; /* Light background */ } /* Trigger Button */ .metro-btn { background-color: #0078d7; /* Metro blue */ color: white; border: none; padding: 10px 20px; font-size: 16px; border-radius: 3px; cursor: pointer; transition: background-color 0.3s ease; } .metro-btn:hover { background-color: #005bb5; /* Darker blue on hover */ } /* Background overlay */ .overlay { display: none; /* Hidden by default */ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */ z-index: 1000; } /* Pop-up box */ .popup { display: none; /* Hidden by default */ position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; /* White background */ color: #333; /* Dark text */ padding: 20px; border-radius: 5px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); z-index: 1001; max-width: 400px; text-align: center; } /* Close button */ .close-btn { float: right; cursor: pointer; font-size: 20px; color: #0078d7; /* Metro blue */ } /* Header styling */ .popup h2 { margin: 0 0 15px; font-size: 20px; color: #0078d7; /* Metro blue */ } /* Paragraph styling */ .popup p { font-size: 14px; line-height: 1.5; } /* Show elements when active */ .active { display: block; } Show Information × Information This is the information displayed in the Metro UI-themed pop-up box. You can customize it as needed! // Get references to the elements const openPopupBtn = document.getElementById('openPopup'); const closePopupBtn = document.getElementById('closePopup'); const overlay = document.getElementById('overlay'); const popup = document.getElementById('popup'); // Function to open the pop-up openPopupBtn.addEventListener('click', () => { overlay.classList.add('active'); popup.classList.add('active'); }); // Function to close the pop-up closePopupBtn.addEventListener('click', () => { overlay.classList.remove('active'); popup.classList.remove('active'); }); // Close the pop-up if the user clicks outside of it overlay.addEventListener('click', () => { overlay.classList.remove('active'); popup.classList.remove('active'); });Flat Colors :
#0078d7(Metro blue), which is used for buttons, headers, and accents.#f4f4f4) to emphasize the flat design.Typography :
'Segoe UI', which is the default font for Metro UI.Minimalistic Design :
border-radius: 5px).box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2)) to give depth without being distracting.Button Styling :
Header and Text :
#0078d7) for emphasis.line-height: 1.5).How It Works
Trigger Button :
Overlay :
Pop-up Box :
×) is styled in Metro blue for consistency.JavaScript Logic :
activeclass for showing/hiding the pop-up.