Css:我需要知道如何将内联块div居中,以便能够将图片放在居中的div的左侧和右侧 [英] Css : I need to know how to center an inline-block div to be able to put pictures at the left and right of the centered div

查看:113
本文介绍了Css:我需要知道如何将内联块div居中,以便能够将图片放在居中的div的左侧和右侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个居中的div,所以我可以在中心div的一侧制作左右浮动图片



我尝试过:



我试过把一个外部div但是我没有解决我的问题,因为我不希望div占用100%的页面

I want to have a centered div so I can make float right and left pictures at the side of the centered div

What I have tried:

I tried putting an outer div but i didnt solved my problems since I dont want the div to take 100% of the page

推荐答案

如果您正在使用display:inline-block;对于div,我们不能将div.need放在使用display:block;为div设置max-width并添加margin:0 auto; for div



.center-div {

max-width:500px;

display:block;

保证金:0自动;

}
If your are use display:inline-block; for div we can't center div.need to use display:block; for and set max-width for div and add margin:0 auto; for div

.center-div{
max-width:500px;
display:block;
margin:0 auto;
}


这篇关于Css:我需要知道如何将内联块div居中,以便能够将图片放在居中的div的左侧和右侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆