Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.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
Css Can';我不知道如何水平居中放置我的内容分区_Css_Html_Center - Fatal编程技术网

Css Can';我不知道如何水平居中放置我的内容分区

Css Can';我不知道如何水平居中放置我的内容分区,css,html,center,Css,Html,Center,我想将我的div居中,这样无论你观看网站的屏幕有多大,它都能完全居中于页面的中间 请帮忙 谢谢 HTML: 我已经试过很多东西,但不明白为什么会有奇怪的表现 谢谢你的帮助试试这个 #div_id { width: 50%; margin: 0 auto; } 您可以尝试以下方法: 测试 您将在上面的JSFIDLE链接中找到工作示例 新年快乐…:)我已经试过左边距:自动;右边距:自动;尝试边距:0自动;谢谢,我要试试那个brb *{ margin: 0 auto 0 auto;

我想将我的div居中,这样无论你观看网站的屏幕有多大,它都能完全居中于页面的中间

请帮忙 谢谢

HTML:

我已经试过很多东西,但不明白为什么会有奇怪的表现 谢谢你的帮助

试试这个

#div_id {
 width: 50%;
 margin: 0 auto;
}
您可以尝试以下方法:


测试
您将在上面的JSFIDLE链接中找到工作示例


新年快乐…:)

我已经试过左边距:自动;右边距:自动;尝试边距:0自动;谢谢,我要试试那个brb
*{
    margin: 0 auto 0 auto;
    text-align: left;
    color: #ffffff;
}

body{
    margin: 0;
    text-align: left;
    font-size: 13px;
    font-family: arial, helvetica, sens-serif;
    color: #ffffff;
    width: 1200px;
    height: auto;
    background: #fdf7e3;
}

header {
    position: fixed;
    width: 100%;
    top: 0;
    background: rgba(0,0,0,0.8);
    z-index: 10;
}

h1{
    color: black;
    text-align: center;
}

.hide
{
    position: fixed;
    width: 100%;
    top: 0;
    background: rgba(255,255,255,1);
    z-index:5;  
    height: 123px;
}
.headertext{
    margin-top: 15px;
    text-align: center;
    color: white;
}

#title{
    font-size: 20px;
    margin: -10px 0 30px 0;
    width: 100%;
    height: 70px;
    border-top: 2px solid #000000;
    border-bottom: 2px solid #000000;
}

#menubar{
    float: left;
    clear: both;
    width: 100%;
    height: 30px;
    list-style: none;
    border-bottom: 2px solid #010000;
}

#menubar ul{
    list-style: none;
    margin-top: -20px;
    text-align: center;
}

#menubar ul li{
    list-style: none;
    display: inline;
    padding-right: 80px;
}

#menubar ul li a{
    color: #ffffff;
    text-decoration: none;
    font-size: 20px;
    font-weight: bold;
}

#menubar ul li a:hover{
    border-bottom: 2px solid #ffffff;
}

#rightmenu{
    margin-top: -20px;
    position: fixed;
    right: 0;
    width: 160px;
    height: 530px;
    list-style: none;
    background: rgba(0,0,0,0.8);
    color: #ffffff;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}

#rightmenu ul{
    margin-top: 23px;
}

#rightmenu ul li{
    display: block;
    padding-bottom: 50px;
}

#rightmenu ul li a{
    font-weight: bold;
    text-decoration: none;
    color: #ffffff;
    font-size: 15px;
    text-align: center;
    margin-left: -15px;
}

#rightmenu ul li a:hover{
    border-bottom: 2px solid #ffffff;
    transition: opacity .5s ease-in;
    opacity: 1;
}

#righttriangle1 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-top: -410px;
   margin-right: 160px;
}

#righttriangle2 {
    width: 0;
    height: 0;
    border-right: 25px solid rgba(0,0,0,0.8);
    border-top: 34px solid transparent;
    border-bottom: 34px solid transparent;
    margin-right: 160px;
}

#righttriangle3 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-right: 160px;
}

#righttriangle4 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-right: 160px;
}

#righttriangle5 {
   width: 0;
   height: 0;
   border-right: 25px solid rgba(0,0,0,0.8);
   border-top: 34px solid transparent;
   border-bottom: 34px solid transparent;
   margin-right: 160px;
}

#leftmenu{
    position: fixed;    
    left: 0;
    margin-top: -20px;
    width: 160px;
    height: 450px;
    list-style: none;
    background: rgba(0,0,0,0.8);
    color: #ffffff;
    border-left: 2px solid #010000;
    border-right: 2px solid #010000;
}

#leftmenu ul{
    margin-top: 23px;
}

#leftmenu ul li{
    display: block;
    padding-bottom: 50px;
}

#leftmenu ul li a{
    font-weight: bold;
    text-decoration: none;
    color: #ffffff;
    font-size: 15px;
    margin-left: -15px;
}

#leftmenu ul li a:hover{
    border-bottom: 2px solid #ffffff;
    transition: opacity .5s ease-in;
    opacity: 1;
}

#lefttriangle{
    margin-top: 89px;
    margin-left: -1px;
    width: 0px; 
    height: 0;
    border-top: 80px solid rgba(0,0,0,0.8);
    border-left: 82px solid transparent; 
    border-right: 82px solid transparent; 
}

#content{
    width: 1000px;
    margin: 0 auto;
    margin-top: 135px;
    color: #000000;
    font-weight: bold;
    text-align: center;
    font-size: 15px;
}

#naturepictures{
    color: black;
    top: 1200px;
    width: 80px;
    height: 300px;
    text-align: center;
    margin-left: 440px;
}

.naturepicture{
    height: 400px;
    width: 600px;
}

.slider{
    margin-top: 20px;
    width: 600px;
    height: 400px;
    overflow: hidden;
    margin: auto;
    border-radius: 10px;
    vertical-align: middle;
}

.shadowbottom{
    background-image:url(../images/shadow.png);
    background-repeat: no-repeat;
    background-position: top;
    width: 850px;
    height: 144px;
    vertical-align: middle;
    margin-top: -50px;
}

.slider img{
    width: 600px;
    height: 400px;
    display: none;
}
#div_id {
 width: 50%;
 margin: 0 auto;
}
<div class="mainwrapper" >
    <div class="innerwrapper">
    <div class="contentdiv">test</div>
    </div>
</div>