Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML |居中_Javascript_Html_Css - Fatal编程技术网

Javascript HTML |居中

Javascript HTML |居中,javascript,html,css,Javascript,Html,Css,当我使用particles.js时,我的图像无法居中。图像居中,但稍微偏离中心。它为什么要这样做?我怎样才能使它居中 html <!DOCTYPE html> <html> <head> <title>particles.js demo</title> <link href="css/style.css" rel="stylesheet"> </head> <body> <div id="par

当我使用particles.js时,我的图像无法居中。图像居中,但稍微偏离中心。它为什么要这样做?我怎样才能使它居中

html

<!DOCTYPE html>
<html>
<head>
<title>particles.js demo</title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<div id="particles-js" width='100%'></div>
<script src="http://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js">
</script>
<script src="js/index.js">
</script>
<img id='downarrow' height="75" width="75" src='images/arrowdown.png'>
</body>
</html>

您正在使用
左:50%-将图像的左边缘置于页面宽度的50%。如果希望图像居中,请添加
transform:translateX(-50%)

正文{
保证金:0;
高度:2000px;
宽度:100%;
}
:-webkit滚动条{
显示:无;
}
#粒子js{
位置:绝对位置;
宽度:100%;
身高:100%;
背景色:#00a4ff;
背景图像:url(“http://i.imgur.com/yHL4C4u.png");
背景重复:无重复;
背景位置:50%50%;
-webkit背景尺寸:封面;
-moz背景尺寸:封面;
-o-背景尺寸:封面;
背景尺寸:封面;
}
#向下箭头{
左边距:50%;
}
img{
位置:绝对位置;
}

使用负片
左边距
将图像拉回到中心:

#downarrow {
    left: 50%;
    margin-left: -37px; /* Half of the image width */
}

如果我想将图像放置在天空图像的底部,我会怎么做?
#downarrow {
    left: 50%;
    margin-left: -37px; /* Half of the image width */
}