Look at the code directly
<div class="cookie"></div>
.cookie{
width:500px;
position:fixed;
left:50%;
bottom:0px;
transform:translateX(-50%);
}
okay! That's it, let me briefly analyze the css for my own sake~
- First of all position: it
fixed
means fixed, so it’s no problem left
Andbottom
have no problem! Must be written together- Well,
tranform
good to write about -
left: 50% , yes, that's the effect!
Then, transform is such an effect!
We want it to be centered, just move 50% of its width to the left←, as shown in the figure:
Finally, don't complain about my little blackboard hahaha