I am struggling to create a modal with the tools and close button appearing on the same line. It should look similar to the image below:
var modal = document.getElementById('myModal');
var btn = document.getElementById("myBtn");
var span = document.getElementsByClassName("close")[0];
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
.modal {
display: none;
position: fixed;
z-index: 1;
top: 0;
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
border: 1px solid #888;
width: 100px;
box-shadow: 0px 8px 16px 0px rgba(4, 4, 4, 0.61);
}
.cButton {
position: realtive;
display: inline-block;
background-color: grey;
width: 100px;
border-top: 1px solid black;
border-bottom: 1px solid black;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.close {
position: absolute;
display: inline;
color: #aaa;
float: right;
font-size: 16px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
<div id="myBtn">Open Modal</div>
<div id="myModal" class="modal">
<div class="modal-content">
<div id="closeButton" class="cButton">
<p>tools</p>
<div class="close">×</div>
</div>
<p>Some text</p>
<p>Some text</p>
<p>Some text</p>
<p>Some text</p>
<p>Some text</p>
</div>
</div>
Additionally, I would like the modal box to have the style shown in the image below for the top.