纯css实现div容器内图片上下左右居中

 时间:2026-02-18 14:10:56

1、新建html文档。

</div>

纯css实现div容器内图片上下左右居中

4、初始化css代码。

<style>

*{ margin:0; padding:0; list-style:none;}

img{ border:none;}

button, input, select, textarea { font-size: 100% }

textarea { font: 14px/20px "微软雅黑" }

button { border: 0 }

li { list-style: none }

img { border: 0; }

a { color: #06c; text-decoration: none; cursor: pointer; outline: none; hide-focus:expression(this.hideFocus = true);}

a:hover { color: #06c; text-decoration: underline }

.left{ float:left;}

.right{ float:right;}

.clear:after{content:"";display:block;visibility:hidden;height:0;clear:both;}

.clear{zoom:1}</style>

纯css实现div容器内图片上下左右居中

5、书写css代码。

.aaa{ width:600px; height:400px; margin:100px auto;text-align:center;vertical-align:middle;display:block;position:relative; background:#ddd;}

.aaa a{display:table-cell;vertical-align:middle;width:600px; height:400px; }

.aaa a img{max-width:600px;max-height:400px; }

6

纯css实现div容器内图片上下左右居中

7、代码整体结构。

纯css实现div容器内图片上下左右居中

8、查看效果。

纯css实现div容器内图片上下左右居中

  • 怎样查看Eclipse的版本及版本代号
  • 如何使用CSS3弹性盒子display:flex布局
  • css如何制作圆角正方形
  • 网页色彩搭配原则
  • dreamweaver中框架集可以在网页中自由调整宽高
  • 热门搜索
    南京免费旅游景点 冬天如何钓鲫鱼 齐云山旅游 如何挑虾线 旅游项目策划书 手机如何连接打印机 如何求值域 如何注册谷歌账号 佰仟金融怎么样 如何下载英雄联盟手游