中心图象在div

编程入门 行业动态 更新时间:2024-10-15 02:32:56
本文介绍了中心图象在div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图在一个div中水平居中的图像,我不明白为什么它不工作...我已经集中图像这么多次,这一次,我只是不明白。 .. 这是我试过...

I'm trying to center horizontally an image in a div, and i don't understand why it isn't working... I've centered images so many times, and this time i just don't understand... Here is what i've tried...

CSS

#cabeca{ position: relative; float: left; width: 100%; height: auto; min-height: 290px; margin: auto; } .cabecasize { width:100%; min-width: 968px; height:auto; min-height: 290px; overflow:hidden; left:0; right: 0; margin: auto; } .cabecafundo{ position: absolute; width: 100vw; left: calc(-50vw + 50%); background-color: black; height: 100%; top:0; z-index: -1; } .overcabeca{ overflow: hidden; display: block; margin: auto; text-align: center; }

HTML

<div id="cabeca"> <div class="overcabeca"> <img src="images/av61.png" alt="av61" class="cabecasize" /> </div> <div class="cabecafundo"> </div> </div>

任何想法

推荐答案

检查下面的代码,我希望它会帮助你。

Check the below code, I hope it will helps you.

.wrap{ position: relative; height: 100vh; width: 100vw; } .midImg{ margin: auto; position: absolute; left:0; right: 0; top: 0; bottom: 0; height: 150px; width: 150px; }

<div class="wrap"> <img src="pbs.twimg/profile_images/473506797462896640/_M0JJ0v8.png" alt="av61" class="midImg" /> </div>

更多推荐

中心图象在div

本文发布于:2023-11-30 03:02:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648503.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图象   中心   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!