首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使标题div适合整个屏幕。

无法使标题div适合整个屏幕。
EN

Stack Overflow用户
提问于 2015-10-13 15:29:12
回答 4查看 200关注 0票数 0

我正在进行的项目中,我将标题的div设置为100%,主容器也是100%,但是左右两边都是由标题填充的。顶部也不是最上面的,但我设法通过应用-ve边距来修正它,但不想在左边和右边这样做。

请帮我解决这个问题,这是CSS和HTML代码:

代码语言:javascript
复制
@font-face{ font-family:'Junction';
 src:url('junction/Junction-webfont.eot');
 src:url('junction/Junction-webfont.eot?iefix') format('eot'),
url('junction/Junction-webfont.woff') format('woff'),
url('junction/Junction-webfont.ttf') format('truetype'),
url('junction/Junction-webfont.svg#webfont') format('svg');

}
#main {
  width: 100%;
  padding: 0;
}
h1 {
  font-size: 2em;
  padding: 1.7%;
}
#header {
  min-width: 100%;
  background-color: #FF6978;
  display: block;
  font-family: Junction, "Times New Roman", sans-serif;
  width: 100%;
  margin-top: -1.6%;
}
代码语言:javascript
复制
<!doctype html>
<html lang="en">

<head>
  <title>Check</title>
  <meta charset="UTF-8">
  <link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>
  <div id="main">
    <!--open main div-->
    <div id="header">
      <h1>Chekcking</h1>
    </div>
    <!--close header-->
  </div>
  <!--close main-->
</body>

</html>

注:我使用嵌入式字体连接,这是不在线的。而且,我也不想增加宽度到120%,并使左边框-ve。请建议另一种方法

太感谢你了,阿尔萨斯

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2015-10-13 15:33:15

您需要从主体和其他元素中删除默认的边距。“通用”重置是一个很好的选择,尽管正确的重置CSS是最佳的。

代码语言:javascript
复制
* {
  margin:0;
  padding:0;
  }

代码语言:javascript
复制
@font-face{ font-family:'Junction';
 src:url('junction/Junction-webfont.eot');
 src:url('junction/Junction-webfont.eot?iefix') format('eot'),
url('junction/Junction-webfont.woff') format('woff'),
url('junction/Junction-webfont.ttf') format('truetype'),
url('junction/Junction-webfont.svg#webfont') format('svg');

}

* {
  margin:0;
  padding:0;
  }

#main {
  width: 100%;
  padding: 0;
}
h1 {
  font-size: 2em;
  padding: 1.7%;
}
#header {
  min-width: 100%;
  background-color: #FF6978;
  display: block;
  font-family: Junction, "Times New Roman", sans-serif;
  width: 100%;
  margin-top: -1.6%;
}
代码语言:javascript
复制
<!doctype html>
<html lang="en">

<head>
  <title>Check</title>
  <meta charset="UTF-8">
  <link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>
  <div id="main">
    <!--open main div-->
    <div id="header">
      <h1>Chekcking</h1>
    </div>
    <!--close header-->
  </div>
  <!--close main-->
</body>

</html>

票数 3
EN

Stack Overflow用户

发布于 2015-10-13 15:33:24

试着添加:

代码语言:javascript
复制
body {
    margin: 0;
}

就像这把小提琴上所显示的那样。

票数 1
EN

Stack Overflow用户

发布于 2015-10-13 15:33:24

只需将marginproperty value of 0添加到体内即可

代码语言:javascript
复制
@font-face{ font-family:'Junction';
 src:url('junction/Junction-webfont.eot');
 src:url('junction/Junction-webfont.eot?iefix') format('eot'),
url('junction/Junction-webfont.woff') format('woff'),
url('junction/Junction-webfont.ttf') format('truetype'),
url('junction/Junction-webfont.svg#webfont') format('svg');

}
body {
  margin: 0;
}
#main {
  width: 100%;
  padding: 0;
}
h1 {
  font-size: 2em;
  padding: 1.7%;
}
#header {
  min-width: 100%;
  background-color: #FF6978;
  display: block;
  font-family: Junction, "Times New Roman", sans-serif;
  width: 100%;
  margin-top: -1.6%;
}
代码语言:javascript
复制
<!doctype html>
<html lang="en">

<head>
  <title>Check</title>
  <meta charset="UTF-8">
  <link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body>
  <div id="main">
    <!--open main div-->
    <div id="header">
      <h1>Chekcking</h1>
    </div>
    <!--close header-->
  </div>
  <!--close main-->
</body>

</html>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33106711

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档