douqu2481 2017-08-08 16:11
浏览 66

100%标题宽度不填充100%宽度?

I have a header and navbar (attached) then 2 input boxes below that. When I resize my screen to a smaller resolution, a scroller bar appears horizontally (which is weird as everything on the page is visible without scrolling), when I move this scroller bar, my header (with width 100%) cuts off and I just see the background underneath it. I have had this problem with multiple websites in the past, how do I fix it? My code is below.

assets/header.php

<html>
<link rel="stylesheet" type="text/css" href="/blog/assets/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/blog/assets/style.css">
<head>

</head>
<body>
  <div class="header"><br><br><br>
    <p>My Blog</p>
  </div>
  <div class="topnav" align="center">
    <a href="/">HOME</a>
    <a href="./latest">LATEST</a>
    <a href="./all">ALL</a>
    <a href="./about">ABOUT</a>
    <a href="./about">SEARCH</a>
  </div>

assets/style.css

@import url('https://fonts.googleapis.com/css?family=Indie+Flower');
body {
   background-color: #D3D3D3;
   margin: 0 0 100px;
   font-family: "PT-Sans", sans-serif;
}

.header {
  display: block;
  width: 100%;
  height: 200px;
  background-image: url("./img/header-img.png");
  background-repeat: no-repeat;
  background-size: 100%;
  background-size:cover;
  background-position: center center;
}

.topnav {
    background-color: #333;
    overflow: hidden;
    position: relative;
    top: 0;
}

.topnav a {
    display: inline-block;
    color: #f2f2f2;
    text-align: center;
    padding: 14px 100px;
    text-decoration: none;
    font-size: 17px;
    text-align: center;
}

.topnav a:hover {
    background-color: #ddd;
    color: black;
}

.topnav a.active {
    background-color: #4CAF50;
    color: white;
}
.header p {
  color: white;
  font-size: 50px;
  text-align: center;
  vertical-align: middle;
  font-family: 'Indie Flower', cursive;
}

index.php

<?php
include($_SERVER["DOCUMENT_ROOT"]."/blog/assets/header.php");
?>
<head>
  <link rel="stylesheet" type="text/css" href="style.css" />
  <title>Create Blog</title>
<form action="send.php" method="POST" class="form">
<input type="text" name="title" placeholder="Title" class="input"><br>
<textarea name="blog-text" placeholder="Blog" class="input"></textarea>
</form>

style.css

.input {
  width: 50%;
}
.form {
  position: relative;
  left: 25%;
}
  • 写回答

6条回答 默认 最新

  • dqq9695 2017-08-08 16:14
    关注

    add this in your stylesheet to fill the header 100%

    .header{
        width: 100%;
        margin-left: 0!important;
        margin-right: 0!important;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示