Yogesh Chauhan's Blog

How to display modal from bottom to top using CSS and JavaScript?

in CSS & JavaScript on October 18, 2020

For modals, we USUALLY use something like this:


//CSS Code

#modal {
    width: 100%;
    height: 0%;
}

and then with JavaScript, we just make the height to 100% when we display the modal.

Now there are few ways to display the modal from bottom. We can use margin-top directly or we can use animation to do the same with animation effect. I am going to discuss the first method.

Solution: Using margin-top


//CSS Code

#modal {
    width: 100%;
    height: 0%;
    margin-top:100%;
}

After that using JavaScript, remove the margin-top by setting it's value to zero along with changing the height to 100%.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
How to import a CSS file using PHP code and not HTML code?PHPSorting Object Arrays in JavaScriptJavaScriptQuery to increment or decrement value in MySQL ignoring negative valuesSQL/MySQLSolution for the error Commit failed – exit code 1 received in Desktop GithubMiscellaneousA complete diagram with building blocks of an Angular applicationAngularHow to redirect or load a new document using JavaScript?JavaScriptHow to change perception and behavior of a person for acceptance of new systems?MiscellaneousColumn and Table Alias in PostgresPostgresHow to apply style to a specific child element using CSS?CSSAccessing and Setting features of JavaScript ObjectsJavaScriptHow to vertically and horizontally align text and image block (without flex or grid) in CSS?CSSWhy does MOV matter in IT or any kind of projects?Miscellaneous