私は親の幅が0のときにネストされたpタグを隠そうとしています。ネストされたpタグは、その幅が0に近づくにつれて親に続き、展開するときに欲しいと思います。私はその何かがシンプルであることを確信しています。親の幅が0の場合、ネストされた要素を隠すにはどうすればよいですか?
HTML:
<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:
.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:
var trigger = $('button');
var deleteBtn = $('.floater1');
trigger.click(function(){
console.log("hello")
deleteBtn.toggleClass('show');
})
うわー、それは簡単でした...迅速な対応に感謝します。 – halfacreyum