HTML+CSS Easy to Get Started with the Boundary of the Box Model

The distance between elements and other elements can be set using margin. Boundaries can also be divided into upper, right, lower and left

Let’s write an example to explain;

First we write a piece of code that does not use boundaries:

<!DOCTYPE html>
  <meta charset="utf-8">
  <style type="text/css">
        border:1px solid red;
    <div id="dv1">php中文网</div>
    <div id="dv2">中华民族伟大复兴</div>

The two divs are together. If I want the distance between the two divs to be 30 pixels, how should I write the css code?


When we add this code, there will be a distance between the two divs

Friends, you can try the right side, bottom side, and left side respectively to see what kind of effect you get

Next Section
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <style type="text/css"> div{ width:200px; height:200px; border:1px solid red; } </style> </head> <body> <div id="dv1">php中文网</div> <div id="dv2">中华民族伟大复兴</div> </body> </html>
submitReset Code