Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
css实现图片在div中居中的方法有哪些_创想鸟

css实现图片在div中居中的方法有哪些

css实现图片在div中居中的方法有哪些

本文为大家介绍了图片在div中居中的四种方法,希望对大家有所帮助。

方法一:

(推荐教程:css视频教程)

html:

立即学习“前端免费学习笔记(深入)”;

  
@@##@@

css

.title {   width: 100%;    font-size: 0;    height: 10%;}.title .content img {    width: 35%;}/*--主要的--*/.content{    display: inline-block;    vertical-align: middle;  }.flag{    display: inline-block;    vertical-align: middle;    height: 100%;    width: 0;  }

方法二:

html

  
@@##@@

css

.title {  display: flex;  justify-content: center;  align-items: center;}.title img {  width: 35%;}//该方法有些旧系统不支持

方法三:

html

 
第三种方法

css

.title {   height: 15%;   font-size: 18px;   position: relative;}.title span {    position: absolute;    top: 50%;    left: 50%;    transform: translate(-50%, -50%);}

方法四:

html

第四种方法

css

 .title {    width: 200px;    height: 200px;    vertical-align: middle;    display: table-cell;    text-align: center;}

相关推荐:CSS教程

css实现图片在div中居中的方法有哪些css实现图片在div中居中的方法有哪些

以上就是css实现图片在div中居中的方法有哪些的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1615878.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
css如何制作饼状图
上一篇 2025年12月24日 05:07:23
深入浅析css中的z-index
下一篇 2025年12月24日 05:07:34

相关推荐

发表回复

登录后才能评论
关注微信