Я скопировал / вставил ваш код в фрагмент ниже, прокомментировал overflow: hidden;
из #header, и, похоже, он работает, не так ли?
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function openDropdown() {
const myDropdown = document.getElementById("myDropdown");
const show = document.getElementById("myDropdown").classList.toggle("show");
if(show){
const {top, left, width} = myDropdown.getBoundingClientRect();
myDropdownClone = myDropdown.cloneNode(true);
myDropdownClone.style.width = `${width}px`;
myDropdownClone.style.top = `${top}px`;
myDropdownClone.style.left = `${left}px`;
myDropdownClone.style.position = 'fixed';
myDropdownClone.id = 'myDropdownClone';
document.body.append(myDropdownClone);
} else {
document.getElementById("myDropdownClone").remove();
}
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.closest('.dropbtn')) {
let dropdowns = document.getElementsByClassName("dropdown-content");
let i;
for (i = 0; i < dropdowns.length; i++) {
let openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
#header {
width: auto;
height: auto;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 40px;
background: #417690;
color: #ffc;
/* overflow: hidden; */
clip-path: polygon(5% 0%, 100% 0%, 100% 100%, 0% 100%);
}
#header {
background: #FFF;
-moz-box-shadow: 0 3px 3px 0 rgba(148, 148, 148, 0.5);
box-shadow: 0 3px 3px 0 rgba(148, 148, 148, 0.5);
padding: 0;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-areas: "logo navbar";
}
.dropbtn {
background-color: #0071ce;
color: white;
/*padding: 16px;*/
font-size: 16px;
border: none;
cursor: pointer;
}
.dropbtn:hover, .dropbtn:focus {
background-color: #005ba6;
}
.dropdown {
position: relative;
display: block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
/*overflow: auto;*/
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
z-index: 1;
right: 0.5rem;
}
.dropdown-content a {
color: black !important;
padding: 1rem 1rem !important;
text-decoration: none;
display: block;
}
.dropdown a:hover {background-color: #ddd;}
.show {display: block;}
<div id="header">
<div id="branding">
</div>
<div id="user-tools">
<strong>My name</strong>.
<a href="#">View site</a>
<a href="#">trans Documentation</a> /
<div class="dropdown">
<button onclick="openDropdown()" class="dropbtn"><img src="" alt="User Menu" style="height: 30px;"></button>
<div id="myDropdown" class="dropdown-content">
<a href="#">Change password</a> /
<a href="#">Log out</a>
</div>
</div>
</div>
</div>
[EDIT] Я отредактировал фрагмент кода, чтобы учесть clip-path: polygon(5% 0%, 100% 0%, 100% 100%, 0% 100%);
, упомянутый в комментариях