How to create: Create a pop-up message
Learn how to use CSS to create pop-up messages (Callout Message).
Pop-up message
Pop-up messages are usually located at the bottom of the page and are used to notify users of some special matters: tips/tricks, discounts, actions to be taken, etc.
Create a pop-up message
Step 1 - Add HTML:
<div class="callout"> <div class="callout-header">Callout Header</div> <span class="closebtn" onclick="this.parentElement.style.display='none';">×</span> <div class="callout-container"> <p>Some text...</p> </div> </div>
If you want to disable the close functionality of the pop-up message, please add a <span>
element, and set a onclick
attribute, which means "When you click me, hide my parent element", i.e. the container <div class="callout">
.
Tip:Use the HTML entity "×
"Create the letter "x"."
Step 2 - Add CSS:
Set styles for the pop-up message box and close button:
/* 弹出消息框 - 固定在页面底部的位置 */ .callout { position: fixed; bottom: 35px; right: 20px; margin-left: 20px; max-width: 300px; {} /* 弹出消息标题 */ .callout-header { padding: 25px 15px; background: #555; font-size: 30px; color: white; {} /* 弹出消息容器/主体 */ .callout-container { padding: 15px; background-color: #ccc; color: black {} /* 关闭按钮 */ .closebtn { position: absolute; top: 5px; right: 15px; color: white; font-size: 30px; cursor: pointer; {} /* 鼠标悬停时更改颜色 */ .closebtn:hover { color: lightgrey; {}
Related Pages
Tutorial:How to Create a Warning Message
Tutorial:How to Create a Sticky Note