I am attempting to dynamically hide a nested paragraph tag based on its parent's width. I want the nested p tag to adjust its visibility as the parent's width changes, either expanding or contracting. I believe there is a simple solution for this, and I appreciate any assistance in advance.
HTML Structure:
<div class="container">
<div class="floater1">
<p id="icon">X</p>
</div>
<div class="floater2">
<p>This is a test</p>
</div>
</div>
<button>click</button>
CSS Styling:
.container {
width: 100%;
height: 35px;
border: 1px solid #000;
}
.floater1 {
float: left;
width: 0px;
height: inherit;
background: red;
text-align: center;
transition: width 200ms ease-in-out;
}
.show {
width: 30px;
}
.floater2 {
height: inherit;
background: yellow;
overflow: hidden;
padding-left: 15px;
}
p {
margin: 0;
line-height: 35px;
}
JS Interaction:
var trigger = $('button');
var deleteBtn = $('.floater1');
trigger.click(function(){
console.log("Button clicked")
deleteBtn.toggleClass('show');
})