The value of the boundary margin in CSS can also be negative. Sometimes we can't believe it. This is an interesting topic. The negative boundary will bring us more novel ideas, it makes our work more exciting and challenging.
Let's take a look at an example. First, let's take a look at the CSS code:
<Style type = "text/css">
# Box1, # box2 {
Float: left;
Width: 200px;
Height: 300px;
Color: # ffffff;
Font-size: 36px;
Text-align: center;
Line-height: 300px;
}
# Box1 {
Border: solid 5px # ff0099;
Background-image: url('bg2.jpg ');
}
# Box2 {
Border: solid 5px # ffff00;
Background-image: url('bg3.jpg ');
}
</Style>
The XHTML structure is as follows:
<Div id = "box1">
Left column
</Div>
<Div id = "box2">
Right column </div>
Running result:
Now we want to change the positions of the left and right columns.
<Div id = "box1">
& Nbsp;
</Div>
<Div id = "box2">
Right column </div>
Replace:
<Div id = "box2">
Right column </div>
<Div id = "box1">
& Nbsp;
</Div>
You can.
However, when pages are complex, various tags are nested with hundreds of lines of code. This seemingly simple location change may take a long time and can certainly achieve the desired results, now, we have another idea to implement:
# Box1 {
Border: solid 5px # ff0099;
Background-image: url('bg2.jpg ');
Margin-left: 105px;
}
# Box2 {
Border: solid 5px # ffff00;
Background-image: url('bg3.jpg ');
Margin-left:-420px;
After running: