javascript - Expand DIV vertically by keeping the footer at the same position when open/hide element -
i have div shown/hide clicking button shown on image below. @ here, when pressing button, want the button @ same position , expand div (content) above (towards top - position 1 instead of bottom - position 2). tried position:absolute;
properties nothing has changed. idea?
here sample html indicating layout:
<body> <div class="content"> //content... </div> <div id=hidden> //hiddent area... </div> <input type="button"> <footer> //footer... </footer> </body>
update:
here second behaviour second sample: want code works explained.
looks may need position: fixed;
, not position: absolute;
. work?
$(function () { $(".expcol").hide(); $("#btncm").click(function () { $(".expcol").slidetoggle(); }); });
/* start praveen's reset fiddle ;) */ * {font-family: 'segoe ui'; margin: 0; padding: 0; list-style: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;} /* end praveen's reset fiddle ;) */ footer {position: fixed; bottom: 0; width: 100%; background: #ccf;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <footer> <button id="btncm">click me</button> <div class="expcol"> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. ratione commodi, tenetur laborum et beatae praesentium animi, repellat cum pariatur nostrum harum hic excepturi cumque, magnam illo neque quam molestias nam. lorem ipsum dolor sit amet, consectetur adipisicing elit. eveniet asperiores sunt sed nemo dignissimos enim tempora quam recusandae cum debitis provident eaque dicta illum, voluptatum expedita rerum vel cupiditate deleniti.</p> </div> </footer>
or if button on bottom:
$(function () { $(".expcol").hide(); $("#btncm").click(function () { $(".expcol").slidetoggle(); }); });
/* start praveen's reset fiddle ;) */ * {font-family: 'segoe ui'; margin: 0; padding: 0; list-style: none; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;} /* end praveen's reset fiddle ;) */ footer {position: fixed; bottom: 0; width: 100%; background: #ccf;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <footer> <div class="expcol"> <p>lorem ipsum dolor sit amet, consectetur adipisicing elit. ratione commodi, tenetur laborum et beatae praesentium animi, repellat cum pariatur nostrum harum hic excepturi cumque, magnam illo neque quam molestias nam. lorem ipsum dolor sit amet, consectetur adipisicing elit. eveniet asperiores sunt sed nemo dignissimos enim tempora quam recusandae cum debitis provident eaque dicta illum, voluptatum expedita rerum vel cupiditate deleniti.</p> </div> <button id="btncm">click me</button> </footer>
Comments
Post a Comment