I have a simple button code to show text on-click. I cannot figure out, however, how to have it with a smooth transition. Any advice is appreciated.
<style>
.my-button {
border: none;
border-radius: 10px;
cursor: pointer;
font-size: 20px;
margin: 100px 0 0 300px;
height: 35px;
width: 100px;
}
#Myid {
display: none;
font-size: 20px;
position: relative;
left: 200px;
top: 20px;
background-color: gray;
width: 300px;
text-align: center;
padding: 150px 0 150px 0;
transition: 10s;
}
</style>
<button class="my-button" onclick="toggleText()">button</button>
<div id="Myid">Text</div>
<div style="width: 100px; height: 100px; background-color: gray;">TEXT</div>
<script>
function toggleText(){
var x = document.getElementById("Myid");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
</script>
<style>
.my-button {
border: none;
border-radius: 10px;
cursor: pointer;
font-size: 20px;
margin: 100px 0 0 300px;
height: 35px;
width: 100px;
}
#Myid {
display: none;
font-size: 20px;
position: relative;
left: 200px;
top: 20px;
background-color: gray;
width: 300px;
text-align: center;
padding: 150px 0 150px 0;
transition: 10s;
}
</style>
<button class="my-button" onclick="toggleText()">button</button>
<div id="Myid">Text</div>
<div style="width: 100px; height: 100px; background-color: gray;">TEXT</div>
<script>
function toggleText(){
var x = document.getElementById("Myid");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
}
</script>