Explore the cutting-edge framework of responsive layout
With the popularity of mobile devices and the rapid development of the Internet, responsive layout has increasingly become an important trend in web design. Responsive layout is to automatically adjust the layout and elements of a web page according to the user's device screen size and resolution so that it can be displayed and used well on different devices. In order to help developers implement responsive layout more conveniently, there are now many excellent cutting-edge frameworks to choose from. This article will introduce several representative responsive layout frameworks and provide detailed code examples.
<!DOCTYPE html> <html> <head> <title>Bootstrap Responsive Layout Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div class="container"> <div class="row"> <div class="col-sm"> <h1>Welcome to our website!</h1> <p>This is a responsive layout example using Bootstrap.</p> </div> <div class="col-sm"> <img src="image.jpg" class="img-fluid" alt="Responsive image"> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/js/bootstrap.bundle.min.js"></script> </body> </html>
In the above code, Bootstrap's CSS and JavaScript files are first introduced, and then .container
and ## are used #.rowCreate a grid layout, using
.col-sm to specify the size of each column. By using the
.img-fluid class, images can be automatically resized according to the screen size. This way, the website will be displayed in the best possible way no matter what device the user is using.
<!DOCTYPE html> <html> <head> <title>Foundation Responsive Layout Example</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/css/foundation.min.css"/> </head> <body> <div class="grid-container"> <div class="grid-x"> <div class="cell"> <h1>Welcome to our website!</h1> <p>This is a responsive layout example using Foundation.</p> </div> <div class="cell"> <img src="image.jpg" alt="Responsive image"> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.6.3/js/foundation.min.js"></script> </body> </html>
.grid-container and
.grid-xCreate a grid layout, using
.cell to specify the size of each cell. This way, the website's layout and elements automatically adjust to the device screen size.
The above is the detailed content of Explore the cutting-edge framework for responsive layout. For more information, please follow other related articles on the PHP Chinese website!