Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
Image 带图像的中心空DIV_Image_Center - Fatal编程技术网

Image 带图像的中心空DIV

Image 带图像的中心空DIV,image,center,Image,Center,我试图将空元素DIV与CSS中定义的图像放在中间。 我想用图像将DIV居中 这很难解释 这里是现场演示 -我希望得到与上面文本相同的居中元素#按钮。我知道元素居中,但图像忽略了它。我想您要找的是在div元素中添加“margin:0 auto;” .nase-portfolio { width: 180px; margin: 0 auto; height: 70px; background: url(images/button.png) no-repeat; } 试一试 请在这里包含您的代码,可

我试图将空元素DIV与CSS中定义的图像放在中间。 我想用图像将DIV居中

这很难解释

这里是现场演示
-我希望得到与上面文本相同的居中元素#按钮。我知道元素居中,但图像忽略了它。

我想您要找的是在div元素中添加“margin:0 auto;”

.nase-portfolio {
width: 180px;
margin: 0 auto;
height: 70px;
background: url(images/button.png) no-repeat;
}
试一试


请在这里包含您的代码,可能还有一个指向您的站点或JSFIDLE的链接作为附加资源。
#button {
display: table;
margin: 0 auto;
text-align: center;
}