代码之家  ›  专栏  ›  技术社区  ›  Tryliom

html css nav获取我的页边距表格顶部

  •  0
  • Tryliom  · 技术社区  · 8 年前

    如果我移除 位置 它可以工作,但它不能再填充所有左侧。

  • app.css(主css文件): https://hastebin.com/fodafsidi.css

  • body{
    背景色:f5f5f5;
    
    }
    
    动画:app logo旋转无限20s线性;
    }
    
    高度:150px;
    
    字体大小:1.5em;
    
    
    文本对齐:居中;
    边距:自动;
    边框样式:凹槽;
    
    颜色:0585e1;
    }
    
    
    
    上边距:15px;
    宽度:150px;
    }
    
    高度:100%;
    }
    想要应用margin-top:50px;

    position

    我不知道为什么会这样,谢谢你的帮助。

    Web page with the issue

    body{
      height: 100vh;
      margin: 0;
      padding: 0;
      background-color: #F5F5F5;
    }
    
    .App {
      text-align: center;
    }
    
    .App-logo {
      animation: App-logo-spin infinite 20s linear;
      height: 80px;
    }
    
    .App-header {
      background-color: #222;
      height: 150px;
      padding: 20px;
      color: white;
    }
    
    .App-title {
      font-size: 1.5em;
    }
    
    .App-intro {
      font-size: large;
    }
    
    table {
      text-align: center;
      width: 500px;
      margin:auto;
      margin-right: 40%;
      border-color: #0585e1;
      border-width: 1px;
      border-style: groove;
      padding: 20px 0;
      background-color: #c9d4e8;
      border-radius: 3px;
      margin-top: 10px;
    }
    
    table input {
      width: 200px;
      border-color: #0585e1;
      border-style: groove;
      padding: 4px;
      font-size: 13px;
      background-color: #c9d4e8;
      color: #0585e1;
      margin:3px 0;
    }
    
    table td {
      color: #0585e1;
    
    }
    
    button {
      color: #0585e1;
      background-color: #c9d4e8;
      margin-top: 15px;
      cursor: pointer;
      width: 150px;
      font-size: 15px;
      border-color: #0585e1;
      border-style: groove;
    }
    
    #navigator {
      background: #354256;
      color: #0585e1;
      height: 100%;
      position: absolute;
    }
    1 回复  |  直到 8 年前
        1
  •  1
  •   Rounin    8 年前

    而不是应用 margin-top: 50px; <body> 元素,应用:

    padding-top: 50px;
    

    position: absolute 对于 #navigator

    #navigator {
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      color: #0585e1;
      background-color: #354256;
    }