Currently, I am in the process of developing a simple clickdummy for an application layout. The layout includes a details view on the right side that should only be visible after clicking a button. I am struggling to figure out how to make this div move using CSS or jQuery.
I attempted to use the CSS attribute visibility
to show and hide the div, but it just appears instead of smoothly moving in from the side.
I also experimented with setting margin-left
on the details view, but this ended up disrupting my entire layout.
What is the best way or best practice to achieve an animated moving div?
You can find my code on jsfiddle. The red details
div is the one intended to move.
function toggleButton() {
}
/*STYLE*/
.window {
height: 100vh;
width: 100%;
overflow-x: hidden;
overflow-y: hidden;
}
.header, .footer {
height: 50px;
color: white;
background-color: black;
width: 100%;
}
.stage {
background-color: white;
height: calc(100% - 100px);
width: 100%;
}
.navigation {
background-color: lightgrey;
width: 250px;
height: 100%;
float: left;
}
.content{
background-color: dimgrey;
height: 100%;
width: calc(100% - 400px);
float: left;
}
.details {
background-color: red;
height: 100%;
width: 150px;
float: right;
}
#test-table {
width: 100%;
}
#test-table td {
text-align:center;
vertical-align:middle;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div class="window">
<div class="header">
header
</div>
<div class="stage">
<div class="navigation">
navigation
</div>
<div class="content">
<table id="test-table" border=1>
<tr>
<th>Name</th>
<th>Age</th>
<th>Place</th>
<th>Details</th>
</tr>
<tr>
<td>John</td>
<td>20</td>
<td>USA</td>
<td><input type="button" onclick="toggleButton()" value="i" /> </td>
</tr>
<tr>
<td>Mary</td>
<td>30</td>
<td>Canada</td>
<td><input type="button" onclick="toggleButton()" value="i" /> </td>
</tr>
<tr>
<td>Tim</td>
<td>40</td>
<td>Germany</td>
<td><input type="button" onclick="toggleButton()" value="i" /> </td>
</tr>
</table>
</div>
<div class="details" id="details">
details
</div>
</div>
<div class="footer">
footer
</div>
</div>
</body>
UPDATE
I came across an interesting solution in this discussion. I tried implementing this method (jsfiddle), but now my red div is too tall. How can I resolve this issue?