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 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Modules and its Core features in JavaScriptJavaScriptThe Difference Between Arrays and Objects in JavaScriptJavaScriptHow to create a vertically rotating texts using CSS?CSSHow to create a multisite network in WordPress?WordPressWhat is Conditional Rendering in React?ReactHow to change CSS with JavaScript?CSSKilling A Project Part 3: How can an organization ensure that a doomed project is killed as early as possible?MiscellaneousA Step by Step Guide to Make RSS in XML For Any Website or Blog For FreeMiscellaneousCREATE DATABASE in PostgreSQLPostgresHow to change perception and behavior of a person for acceptance of new systems?MiscellaneousHow to modify the latest post array using get_posts() in WordPress?WordPressUse SwiperJS to create mobile touch sliders fastMiscellaneous