html - 我网页右侧的空白

标签 html css

每当我放大时,我的网页右侧有一个奇怪的空间。空间变大了。谁能帮我摆脱它。

这是我的 html:

<html>
<head>
    <title>thesis</title>
    <link rel = "stylesheet" href = "styles and pics/index.css">
</head>
<body>
<div id = "outer_wrapper">
    <header>
        <section>
            <input type = "text" id = "username" name = "username" class = "text" placeholder = "E-mail"/>
            <input type = "password" id = "password" name = "password" class = "text" placeholder = "Password"/>
            <input type = "submit" id = "submit_login" name = "submit_login" class = "submit" value = "login"/>
        </section>
    </header>
    <footer>
        footer
    </footer>
</div>  
</body>

这是我的CSS:

*{ padding:0px; margin:0px; }
body{ text-align:center;}
#outer_wrapper{ width:100%; height:700px; background-color:yellow; position:relative;}
header{ background-color:blue;height:70px;display:block;position:absolute;top:0px;width:100%;}
header section{ position:relative;top:20px;left:120px;}
.text{ height:25px;width:200px;padding-left:5px;}
#submit_login{height:25px;width:70px;background-color:green;border:0px;outline:none;cursor:pointer;color:white;}
.text,#submit_login{ margin-left:10px;}
footer{background-color:blue;height:40px;position:absolute;bottom:0px;width:100%;}

最佳答案

section { left: 120px; 导致了这个问题。默认情况下,section 继承 width: 100%,因此将它向左移动会使总宽度增加 120px。

假设您希望标题部分向左偏移 120 像素,至少有两种方法可以解决此问题:

  1. 更改 部分 { left: 120px; } 部分 { margin-left: 120px;
  2. overflow: hidden; 添加到标题元素,即 header { overflow: hidden; }

否则只需删除 left: 120px;

关于html - 我网页右侧的空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25375931/

相关文章:

html - 如何使用 bootstrap 2.3.2 在 span 中水平居中表单?

html - flexslider-右侧留白

html - 水平表格溢出 CSS

javascript - 如何在页面加载时自动播放嵌入 YouTube 视频?

html - 如何从 Prestashop 中的订单摘要中删除文本

javascript - 将 getElementById 切换为 ClassName 以创建弹出窗口不起作用

c# - 从代码后面带参数调用 javascript 函数

javascript - 如何使用 amCharts 舍入用作元素符号的图像?

javascript - 基于 CSS 类在文本区域内动态分配字符限制

html - CSS3 Crossfading 各种图像