html - 如果我缩小页面,我的网页将不会居中,有什么提示吗?

标签 html css

No Zoom out 1440x990 67% Chrome [无缩小 1440x990 67% Chrome

Zoomed out to 25%

body{
    margin:0;
    padding:0;
    
}
.no-float{
    clear:both;
}

/*Menubar*/
#anime-logo{
    position:relative;
    top:140px;
    left:321px;
    width:170px;
    height:150px;
   
}

#menubar{
    width:100%;
    max-width:1200px;
    margin:0 auto;
    float:left;
    padding-left:150px;
    
    
}

#menubar h1{
    font-family:'chicle';
    text-align:center;
    font-size:80px;
    position:relative;
    top:-10px;
    left:40px;
}

#menubar a{
    text-decoration:none;
    color:white;
    background-color:#000000;
    font-size:40px;
    font-family:'tangerine';
    padding:0 30px 0 15px;
    margin-left:90px;
    
    
}

#menubar a:hover{
    color:#f3baa5;
}

#menubar .current{
    color:#f3baa5;
}

.menubar-options{
    border-bottom:1px black solid;
    position:relative;
    top:-150px;
    
}

/*Main-Article*/
#main-article{
    width:1200px;
    margin:0 auto;
    float:left;
    position:relative;
    top:-100px;
    padding-left:215px;
    
    
    
}

#hanebado-logo{
    width:1070px;
    height:500px;
    
    
    
}

#main-article a{
    text-decoration:none;
    color:#262626;
    font-family:'syncopate';
}

#main-article a:hover{
    color:#a6a6a6;
    
    
}

#main-article p{
    font-size:20px;
    max-width:1070px;
    font-family:'IBM Plex Mono';
}

.read-more{
    font-size:20px;
}
<!DOCTYPE html>
    <html>
        <head>
            <title>Anime World</title>
            <link rel='stylesheet' type='text/css' href='css/style.css'>
            <meta charset='utf-8'>
            <link href="https://fonts.googleapis.com/css?family=Chicle|IBM+Plex+Mono|Syncopate|Tangerine" rel="stylesheet">


        </head>
        <body>
            <div id='menubar'>
                <div class='menubar-options'>
                <img id='anime-logo' src='./img/anime-logo.jpg'><h1>Anime World</h1>
                <a href=''><span class='current'>Home</span></a>
                <a href=''>Top Series</a>
                <a href=''>Merch</a>
                <a href=''>About us</a>
                <a href=''>News</a>
                </div>
            </div>
                
                <div class='no-float'></div>
            
            <div id='main-article'>
                <a href=''><img id='hanebado-logo' src='./img/hanebado-logo.jpg'>
                <h1>Hanebado! Episode 12 review</h1></a>
                <p>If this is "above average" animation, could you point me towards the god tier animation please. Not trying to be slaty or anything, I started watching anime relatively recently and to me
                this is some of the best I've seen(tho I haven't taken the time to like rank them or anything) so I'm just wondering. <a class='read-more' href=''>Read more...</a> </p>
            </div>
        </body>
    </html>

如何在缩小后保持所有内容居中?一周前刚开始学习 HTML/CSS,对页面上的定位和 div 内容不太了解,所以这可能是我的 css super 困惑的原因,或者这就是我的想法。

有什么建议吗?

最佳答案

您需要使用百分比。示例:

#main-article{
    width: 90%;
    margin:0 auto;
    position:relative;
    padding: 0 125px;
}

并使用响应式元标记,例如:

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

并且...如果您了解基本...也许可以帮助您理解 Bootstrap 或 Materialise 或类似的网格系统

Bootstrap Materialize

关于html - 如果我缩小页面,我的网页将不会居中,有什么提示吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52504956/

相关文章:

javascript - 如何使用Javascript向具有自己当前功能的复选框添加更多功能

jQuery 选择。一个接一个地查找元素

html - CSS 子绝对内容重叠父内容

javascript - jquery UI 按钮太宽虽然 padding = 0

html - 良好的编码习惯/模块化 HTML 结构

php - 如果 mysql 中存在记录,如何构建 php 代码以填充表单中的 280 个字段

javascript - 将鼠标悬停在子 li 上时更改父 div 背景

css - 移动设备上的 Comic Sans MS

jquery - 在不破坏动画效果的情况下将 'flip card' div 放置在页面的不同部分

css - 元素 &lt;header&gt; 或 <section> 在结构上是否与 <div> 不同?