How to float (fix) the bottom of the page? Privacy policy or something

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~

  1. First of all position: it fixedmeans fixed, so it’s no problem
  2. leftAnd bottomhave no problem! Must be written together
  3. Well, tranformgood to write about -

left: 50% , yes, that's the effect!

Insert picture description here

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:

Insert picture description here
Finally, don't complain about my little blackboard hahaha

Guess you like

Origin blog.csdn.net/weixin_43814775/article/details/114710874