用于移动设备的响应式按钮,按钮需要堆叠成一列

问题描述 投票:1回答:1

我的内容需要适应所有屏幕尺寸,我快到了。按钮需要堆叠成整齐的列,但有一些阻止此情况的发生。请帮助提供有关如何解决此问题的想法。查看到目前为止的工作。在此先感谢,感谢您在此主题上的任何帮助。问候

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>New Layout for CW work</title>
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="menu-buttons.css">
  <link rel="stylesheet" href="dropdown-menu.css">

  <style>
    /*Conent menu buttons*/
    
    section {
      background-color: #ede6c1;
      padding: 15px;
      text-align: center;
    }
    
    article {
      padding: 10px;
      font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    }
    
    .row {
      display: -ms-flexbox;
      /* IE10 */
      display: flex;
      justify-content: center;
    }
    
    .column {
      -ms-flex: 50%;
      /* IE10 */
      flex: 0 1 auto;
      margin: 30px;
    }
    
    .menu-button {
      display: block;
      box-sizing: border-box;
      background-color: rgba(85, 100, 83, 0.8);
      padding: 20px 0;
      font-size: 30px;
      margin: 10px 0;
      width: 200px;
      border-radius: 25px;
      box-shadow: 5px 5px 5px rgba(71, 69, 69, 0.787);
    }
    
    .menu-button:hover {
      box-shadow: 1px 1px 1px rgba(71, 69, 69, 0.787);
      color: black;
    }
    
    a {
      color: black;
      text-decoration: none;
    }
    
    a:hover {
      color: rgba(71, 69, 69, 0.787);
      text-decoration: none;
    }
    
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }
    
    body {
      margin: 1em;
      font: 1.2em/1.3em 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Roboto-Light', 'Roboto Light', 'Roboto', 'Segoe UI Web Light', 'Segoe UI Light', 'Segoe UI Web Regular', 'Segoe UI', Helvetica, Arial, sans-serif;
      color: #fff;
    }
    
    h1 {
      font-weight: normal;
      text-align: center;
    }
    
    p {
      margin: 0 0 1em 0;
    }
    
    #main {
      margin: 0;
      padding: 0;
      display: -webkit-flex;
      display: flex;
      -webkit-flex-flow: row;
      flex-flow: row;
    }
    
    header,
    footer,
    #main>article,
    #main>nav,
    #main>aside {
      margin: 4px;
      padding: 1em;
    }
    
    #main>article {
      background: #996;
      -webkit-flex: 4 1 0;
      flex: 4 1 0;
      -webkit-order: 2;
      order: 2;
    }
    
    #main>nav,
    #main>aside {
      background: #663;
      -webkit-flex: 1 6 0;
      flex: 1 6 0;
    }
    
    #main>nav {
      -webkit-order: 1;
      order: 1;
    }
    
    #main>aside {
      -webkit-order: 3;
      order: 3;
    }
    
    header,
    footer {
      min-height: 80px;
    }
    
    header {
      background: #633;
      display: flex;
    }
    /*Header top*/
    
    .header {
      overflow: hidden;
      background-color: #f1f1f1;
      padding: 10px 10px;
    }
    
    .header a {
      float: left;
      color: black;
      text-align: center;
      padding: 12px;
      text-decoration: none;
      font-size: 18px;
      line-height: 25px;
      border-radius: 4px;
    }
    
    .header a.logo {
      font-size: 25px;
      font-weight: bold;
      display: flex;
      justify-content: center;
    }
    
    .header a:hover {
      background-color: #ddd;
      color: black;
    }
    
    .header a.active {
      background-color: dodgerblue;
      color: white;
    }
    
    .header-right {
      float: right;
    }
    
    @media screen and (max-width: 500px) {
      .header a {
        float: none;
        display: block;
        text-align: left;
        padding: 5px;
      }
      .header-right {
        float: none;
      }
    }
    /*   Back button CSS*/
    
    .button {
      display: inline-block;
      border: none;
      padding: 1rem 2rem;
      margin-right: 20px;
      border-radius: 4px;
      text-decoration: none;
      background: dodgerblue;
      color: #ffffff;
      font-family: sans-serif;
      font-size: 1rem;
      cursor: pointer;
      text-align: center;
      transition: background 250ms ease-in-out, transform 150ms ease;
      -webkit-appearance: none;
      -moz-appearance: none;
    }
    
    .button:hover,
    .button:focus {
      background: #434344;
    }
    
    .button:focus {
      outline: 1px solid #fff;
      outline-offset: -4px;
    }
    
    .button:active {
      transform: scale(0.99);
    }
    /*  back button CSS end*/
    /*header bottom*/
    
    footer {
      background: #c66;
    }
    /* Too narrow to support three columns */
    
    @media all and (max-width: 640px) {
      #main, #page {
        -webkit-flex-flow: column;
        flex-flow: column;
      }
      #main>article,
      #main>nav,
      #main>aside,
      #main>.row,
      #main.article {
        /* Return them to document order */
        -webkit-order: 0;
        order: 0;
      }
      #main>nav,
      #main>aside,
      header,
      footer,
      button,
      #main>.article,
      .row {
        min-height: 50px;
      }
    }
    
    @media all and (max-width: 800px) {
      #main>.row, #main.article {
        /* Return them to document order */
        -webkit-order: 0;
        order: 0;
        display: flex;
        flex-direction: column;
      }
    }
  </style>

</head>



<body>

  <div class="header">
    <a href="" class="logo"><img src="images/cw_logo.png"> </a>
    <div class="header-right">
      <a class="active" href="#home">Home</a>
      <a href="[email protected]">[email protected]</a>
      <a href="#about">
        <p>1234567890</p>
      </a>
      <button class="button" onclick="goBack()">Go Back</button>
    </div>
  </div>


  <!-- Drop down menu content-->
  <div class="header-dropdown-menu">

    <ul class="top-nav">
      <li class="top-menu-nav"><a href="#">Menu</a>
        <ul class="sub-nav">
          <li><a href="#">wood Type</a></li>
          <li><a href="#">News</a></li>
          <li><a href="#">Specification</a></li>
          <li><a href="#">Pricing</a></li>
          <li><a href="#">Images</a></li>
          <li><a href="#">FAQ</a></li>
        </ul>
      </li>
    </ul>
  </div>

  <div id="main">
    <nav>image in here</nav>
    <aside>image in here</aside>


    <article>

      <div class="row">
        <div class="column">

          <a class="menu-button" href="../Wood-Type/woodtype.html" role="button">Wood
                  type</a>


          <a class="menu-button" href="../Wood-Type/.html" role="button">Specification</a>

          <a class="menu-button" href="../Wood-Type/.html" role="button">Pricing</a>

        </div>

        <div class="column">
          <a class="menu-button" href="../news/news.html" role="button">News</a>


          <a class="menu-button" href="../Wood-Type/.html" role="button">FAQ</a>

          <a class="menu-button" href="../Wood-Type/index-wood-type.html" role="button">Images</a>

        </div>
      </div>
    </article>


  </div>
  <footer>
    Footer
  </footer>
  <!-- partial -->

</body>

</html>
html css responsive screen-size device-width
1个回答
0
投票

我看到了你的问题,所以我回答了你的问题。

所以我只给出了时尚的下拉列表和按钮的代码。

html代码

<div class="dropdown">
  <button class="dropbtn">Dropdown</button>
  <div class="dropdown-content">
  <a href="#">wood type</a>
  <a href="#">news</a>
  <a href="#">specification</a>
    <a href="#">pricing</a>
    <a href="#">images</a>
    <a href="#">faqs</a>
  </div>
</div>

和css

.dropdown {
  position: relative;
  display: inline;

}

    .dropbtn {
  background-color: yellow;
  color: white;
  padding: 16px;
  font-size: 16px;
  border: none;
  cursor: pointer;
      width: 17.82%;
      margin: 0px 4px;
}

    .dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 620px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

    .dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: inline;
}

.dropdown-content a:hover {background-color: #f1f1f1}

.dropdown:hover .dropdown-content {
  display: inline;
}

.dropdown:hover .dropbtn {
  background-color: #3e8e41;
}
© www.soinside.com 2019 - 2024. All rights reserved.