Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在柔性div中垂直和水平居中图像_Html_Css_Image - Fatal编程技术网

Html 在柔性div中垂直和水平居中图像

Html 在柔性div中垂直和水平居中图像,html,css,image,Html,Css,Image,我有一个带有图像的div,还有一个div。我可以上传任何大小的图像,但有一些规则: 1) 如果我上传相册图片(宽度>高度),图片将被裁剪为246x246px并居中; 2) 如果我上传一张肖像画(高度>宽度),并且它的高度超过328px,图片会被裁剪并居中 我尝试了很多不同的方法来解决这些问题,但都不管用,有时图片会与下面的白色div重叠。 谢谢大家, <!DOCTYPE> <html> <head> <style type="te

我有一个带有图像的div,还有一个div。我可以上传任何大小的图像,但有一些规则: 1) 如果我上传相册图片(宽度>高度),图片将被裁剪为246x246px并居中; 2) 如果我上传一张肖像画(高度>宽度),并且它的高度超过328px,图片会被裁剪并居中

我尝试了很多不同的方法来解决这些问题,但都不管用,有时图片会与下面的白色div重叠。 谢谢大家,

<!DOCTYPE>
<html>
    <head>
        <style type="text/css"> 
            body { 
                padding:0; 
                margin:0; 
                font-family: 'Helvetica', arial; 
                font-size:15px; 
                color:{color:Text}; 
                background:orange; 
            } 


            #container { 
                margin: 20px 400px;

                -webkit-box-sizing: border-box; 
                -moz-box-sizing: border-box;    
                box-sizing: border-box; 

                overflow: hidden; 
                padding: 17px; 
                position: fixed; 

                width: 280px; 
                height: 800px;

                background: black;


            } 



        #container  #logo {
            display: block;
            width:246px;
            max-height:328px; 
            min-height:246;


            margin: 0 0 17px;
            border: 3px solid red;
        }

        #white {
            width: 246px;
            height: 320px;
            background: white;
        }
        </style>
    </head>

    <body>
        <div id="container">
            <center>

                    <img src="{image:Picture}" id="logo" />

                    <div id="white">
                    </div>

            </center>
        </div>
    </body>
</html>
试试这个解决方案

img{
背景:#fff;
边框:1px实心#999;
高度:50px;
宽度:100px;
}
html,正文{高度:100%;框大小:边框框;}
.容器{
宽度:100%;
身高:100%;
背景:#eee;
显示:-网络工具包盒;
-webkit盒方向:水平;
-webkit盒包:中心;
-webkit框对齐:居中;
显示器:-moz盒;
-moz盒方向:水平;
-莫兹盒包装:中心;
-moz框对齐:居中;
显示:框;
盒子方向:水平;
盒式包装:中间;
框对齐:居中;
}


将添加
溢出:隐藏
#徽标
帮助?否。上传750x1825px图片并拉伸
#container {
            width:246px;
            height:328px; 

            background:url(absbsb.jpg) no-repeat center;
            background-size: cover;
        }