Hey there, I've encountered a problem and was wondering if you could assist me with it.
In the code snippet provided below, you'll see that there are elements with:
transform: translate(0,0);
Within these elements, there is a "dropdown" element that appears upon clicking a button.
The issue arises when parts of this dropdown end up hidden behind other elements. After some investigation, I realized that this is due to the parent element having the transform property.
https://i.sstatic.net/OB7us.png
This is just a simplified example; my actual code is more extensive. Unfortunately, I'm unable to remove the transform property.
Is there a CSS-only solution to this dilemma? Your insights would be greatly appreciated!
Cheers!!
$(document).ready(function() {
$('button[name="button"]').click(function(e) {
$(e.currentTarget).parent().find('.template-options-dropdown').toggleClass('open');
});
});
.boxes {
list-style-type: none;
}
.boxes >li {
float: left;
width: 100px;
height: 100px;
background-color: red;
margin: 5px;
transform: translate(0, 0);
}
.download-container {
background: rgba(40, 39, 39, 0.8);
bottom: 0;
position: absolute;
text-align: center;
width: 100%;
}
.download-container .dropdown-container {
display: inline-block;
position: relative;
}
.download-container .dropdown-container button {
background: #0bb9ab;
color: #fff;
padding: 6px 12px;
}
.template-options-dropdown {
list-style-type: none;
text-align: left;
padding: 0;
position: absolute;
background-color: #111;
visibility: hidden;
}
.template-options-dropdown.open {
visibility: visible;
}
.template-options-dropdown li a {
color: white;
text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="boxes">
<li>
<div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
<a href="#">Original</a>
</li>
<li>
<a href="#">Thumb</a>
</li>
<li>
<a href="#">Mobile</a>
</li>
<li>
<a href="#">Tab</a>
</li>
<li>
<a href="#">Web</a>
</li>
<li>
<a href="#">Large web</a>
</li>
</ul>
</div>
</div>
</li>
<li><div class="download-container">
<div class="dropdown-container">
<button type="button" name="button">Download</button>
<ul class="template-options-dropdown">
<li>
<a href="#">Original</a>
</li>
<li>
<a href="#">Thumb</a>
</li>
<li>
<a href="#">Mobile</a>
</li>
<li>
<a href="#">Tab</a>
</li>
<li>
<a href="#">Web</a>
</li>
<li>
<a href="#">Large web</a>
</li>
</ul>
</div>
</div></li>
… (content continues)
</ul>