css背景图居中
DIV+CSS 2023/6/7 21:14:22 点击:不统计
<本文原载于www.forasp.cn>
在写前台页面的时候,遇到了需要 图片作为div 背景的情况,怎么设置css背景图居中呢,看下面的代码
实现css 背景图居中
<style>
.bg_center{
border: solid 1px red;/*边框颜色*/
background-image: url('/static/images/admin.png');/*背景图片地址*/
background-repeat: no-repeat; /*不重复显示*/
background-position: center; /*这里就是关键设置居中了*/
height: 100px;
width: 100px;
}
</style>
<div class="bg_center">
这里是层内显示内容
</div>
以上就是css
<%77w%77%2Ef%6F%72p%73%70%2Ec%6E>