微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

有没有办法让html按钮连接到顶部

如何解决有没有办法让html按钮连接到顶部

我一直在尝试将 CSS 按钮连接到顶部,但我什么也想不通 我把 w3 学校的代码写对了 here

要求的结果:

image

这就是我想要做

解决方法

是的,你可以,所以首先你需要删除它

    [+] Building 5.8s (5/5) FINISHED                                                                                                                                                                          
 => [internal] load build definition from Dockerfile                                                                                                                                                 0.0s
 => => transferring dockerfile: 247B                                                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                                    0.0s
 => => transferring context: 34B                                                                                                                                                                     0.0s
 => [internal] load metadata for docker.io/library/python:3.8.10-slim-buster                                                                                                                         2.6s
 => CACHED [1/2] FROM docker.io/library/python:3.8.10-slim-buster@sha256:c9dc8cd1171771e7f0def12be61d7bb340480e73b4e78acf3464ed0c3347dabd                                                            0.0s
 => ERROR [2/2] RUN apt-get update && apt-get install --no-install-recommends -y   build-essential   libpq-dev                                                                                       3.1s
------                                                                                                                                                                                                    
 > [2/2] RUN apt-get update && apt-get install --no-install-recommends -y   build-essential   libpq-dev:                                                                                                  
#5 0.751 Get:1 http://deb.debian.org/debian buster InRelease [121 kB]                                                                                                                                     
#5 0.751 Get:2 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]                                                                                                              
#5 0.967 Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]                                                                                                                            
#5 1.155 Get:4 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]                                                                                                                          
#5 1.204 Get:5 http://security.debian.org/debian-security buster/updates/main amd64 Packages [290 kB]
#5 2.833 Err:4 http://deb.debian.org/debian buster/main amd64 Packages
#5 2.833   Hash Sum mismatch
#5 2.833   Hashes of expected file:
#5 2.833    - Filesize:7906864 [weak]
#5 2.833    - SHA256:935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda
#5 2.833    - MD5Sum:ba791e511a2a4b6523ac06f404e32f42 [weak]
#5 2.833   Hashes of received file:
#5 2.833    - SHA256:3dbff74a7005b0214ed17ad72a4724cb91919d8d0221b5297f98f6153606bcaa
#5 2.833    - MD5Sum:f24d4da07e9d1e5bccd9d324cb36dd20 [weak]
#5 2.833    - Filesize:7906864 [weak]
#5 2.833   Last modification reported: Sat,27 Mar 2021 09:33:56 +0000
#5 2.833   Release file created at: Sat,27 Mar 2021 09:55:13 +0000
#5 3.000 Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [10.9 kB]
#5 3.020 Fetched 8447 kB in 3s (3163 kB/s)
#5 3.020 Reading package lists...
#5 3.053 E: Failed to fetch http://deb.debian.org/debian/dists/buster/main/binary-amd64/by-hash/SHA256/935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda  Hash Sum mismatch
#5 3.053    Hashes of expected file:
#5 3.053     - Filesize:7906864 [weak]
#5 3.053     - SHA256:935deda18d5bdc25fb1813d0ec99b6e0e32a084b203e518af0cf7dc79ee8ebda
#5 3.053     - MD5Sum:ba791e511a2a4b6523ac06f404e32f42 [weak]
#5 3.053    Hashes of received file:
#5 3.053     - SHA256:3dbff74a7005b0214ed17ad72a4724cb91919d8d0221b5297f98f6153606bcaa
#5 3.053     - MD5Sum:f24d4da07e9d1e5bccd9d324cb36dd20 [weak]
#5 3.053     - Filesize:7906864 [weak]
#5 3.053    Last modification reported: Sat,27 Mar 2021 09:33:56 +0000
#5 3.053    Release file created at: Sat,27 Mar 2021 09:55:13 +0000
#5 3.053 E: Some index files failed to download. They have been ignored,or old ones used instead.
------
executor failed running [/bin/sh -c apt-get update && apt-get install --no-install-recommends -y   build-essential   libpq-dev]: exit code: 100

比你添加这个

<div class="btn-group">
  <button class="notbutton">no text here ToTaLy No TeXt YAYAYAYAYAYAYAYA</button>
</div>

并且您还从 .btn-group { top:0; position: absolute; width: 100%; background-color: #282a35; border-bottom: 8px solid #303740; }

的 css 中删除了这一行
.btn-group .button

比你基本上有以下几点:

border-bottom: 4px solid #303740;

,

问题不在于您的代码。问题是该示例与您遇到的问题相同。如果在全页视图中打开代码,您会看到 notbutton 元素将移至顶行。如果缩小浏览器窗口,notbutton 元素有时会跳到下一行。

这是一个使用包装器 <nav> 元素和 flexbox 用于 .btn-group 元素的解决方案。

<!DOCTYPE html>
<html>

<head>
  <style>
    p,h1,h2,h3,h4,h5,h6 {
      color: #ffffff;
    }
    
    .btn-group .button {
      background-color: #282a35;
      /* Dark */
      color: #ffffff;
      padding: 15px 32px;
      text-align: center;
      text-decoration: none;
      font-size: 16px;
      cursor: pointer;
      border: none;
      border-bottom: 4px solid #303740;
    }
    
    .btn-group .button:hover {
      background-color: #000000;
    }
    
    .btn-group .notbutton {
      background-color: #282a35;
      /* Dark */
      color: #282a35;
      padding: 0;             /* Remove padding from .notbutton */
      text-align: center;
      text-decoration: none;
      font-size: 16px;
      cursor: cursor;
      border: none;
      border-bottom: 4px solid #303740;
      -moz-user-select: -moz-none;
      -khtml-user-select: none;
      -webkit-user-select: none;
      /*
     Introduced in IE 10.
     See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/
   */
      -ms-user-select: none;
      user-select: none;
    }
    
    nav,.btn-group {              /* make the nav and .btn-group flexbox */
      display: flex;
      flex-flow: row nowrap;
    }
  </style>
</head>

<body style="background-color:#1a1a1b;">

  <!-- Wrap your form and btn-group in another element such as <nav> -->
  <nav>
    <form action="https://www.google.com">
      <div class="btn-group">
        <button class="button">Area</button>
        <button class="button">Area1</button>
        <button class="button">Area2</button>
      </div>
    </form>
    <div class="btn-group">
      <button class="notbutton">no text here ToTaLy No TeXt YAYAYAYAYAYAYAYA</button>
    </div>
  </nav>

  <p style="clear:both"><br>the website</p>

</body>

</html>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。