I just learned some html yesterday, and I couldn't wait to make a search bar on JD.com. I did make it, but when I was checking out the shopping cart, I didn't know how to add a number displayed on it. If I want the number to move with the shopping cart, I have to position them together. Positioning definitely requires position. First, set the position of the div with the number to absolute, which gives me a sense of layering. Because the parent tag of the position of the number is body, I can also set top and left to the desired position with the shopping cart. However, if I change the margin of the shopping cart, the two cannot move together, so I set the position of the shopping cart to relative, so that the parent tag of the position of the number becomes the shopping cart. No matter how the margin of the shopping cart is adjusted, the number will move with it... Copy code The code is as follows:<html> <head> <title>day03.html</title> <style type="text/css"> /*First write a position div*/ #car{ width:150px;height:30px; background: #999999; color:white;text-align:center; line-height: 30px;margin: 232px 300px; border:1px solid black;position: relative; } #num{ width:20px;height:20px;background: red; color:white;text-align:center; line-height:20px;position: absolute; top:-15px;left:25px; } </style> </head> <body> <div id="car"> Go to the shopping cart to pay <div id="num">0</div> </div> </body> </html> |
>>: MySQL Series 14 MySQL High Availability Implementation
1. Autoflow attribute, if the length and width of...
This article uses a specific example to introduce...
Operation effect: html <div class="tic-ta...
In the process of making web pages, we often use f...
This article uses examples to describe various co...
introduce Have you ever spent a whole day trying ...
When developing and debugging a web application, ...
In MySQL, we often use order by for sorting and l...
Preview address: https://ovsexia.gitee.io/leftfix...
Environment Preparation Before starting any opera...
Some people say that doing advertising is like bei...
Table of contents Preface sql_mode explained The ...
Click here to return to the 123WORDPRESS.COM HTML ...
Why did I use this? It all started with the makin...
Effect picture: The implementation code is as fol...