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
Preface This article introduces the installation ...
background Today, I was browsing CodePen and saw ...
The previous article wrote about how to manually ...
In web development, since the checkbox is small an...
Install Jenkins via Yum 1. Installation # yum sou...
Table of contents Related dependency installation...
This article mainly introduces how to build a MyS...
Pull the image docker pull season/fastdfs:1.2 Sta...
Table of contents 1. Introduction 2. Prepare the ...
To install a virtual machine on a Windows system,...
Preface: After studying the previous article, we ...
In this article, we will look at how to develop a...
What is the role of http in node The responsibili...
drop procedure sp_name// Before this, I have told...
Table of contents Where is the source code of the...