My dilemma involves creating a div
using CSS
with an added X
at the top-right corner using the before pseudo-class
. How can I implement a function to close this div by clicking on the X with the assistance of javascript
?
https://i.sstatic.net/Z5uSq.png
CSS
.validation-summary-errors{
position: absolute;
width: 260px;
padding: 20px;
box-sizing: border-box;
top: 50%;
left: 50%;
background-color: #fff;
text-align: center;
font-size: 14px;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
border-radius: 4px;
border: #000 solid 1px;
box-shadow: #232323 1px 1px 6px;
}
.validation-summary-errors:before {
display: block;
content: "X";
position: absolute;
right: -15px;
top: -15px;
background-color: rgba(0, 0, 0, 0.85);
padding: 5px;
border-radius: 50%;
font-size: 16px;
color: #fff;
width: 29px;
box-sizing: border-box;
}
HTML in View (Edit)
<div class="message-error">
@validationSummary
</div>