使用CSS / HTML5进行大小调整问题

时间:2017-10-05 22:01:34

标签: html css html5 resize alignment

我目前正在一个小型网站上工作。关于我的一些按钮的定位,尺寸和对齐,我有几个问题......

  1. 我希望我的盒子始终位于屏幕中央(✔)。

  2. 我想有一个自适应按钮方案,以便当窗口变得足够小时它们堆叠在一起。目前,它们全部捆绑在一起,一旦页面达到一定的大小就无法读取(如下图所示)。

  3. 我希望我的注册文本位于我的两个按钮的底部。它目前位于它们的右侧。此外,当窗口处于一定大小时,盒子需要在彼此的顶部而不是在旁边,我希望我的注册文本跟随并进入第二个框。下面我将分享我的代码( html& CSS ),我将发送网站当前状态的图片。

  4. 提前致谢。

    CSS CODE

    body{
        margin-top: 300px;
        text-align: center;
    }
    
    
    .ownerButton, .employeeButton {
        background-color: #333;
        text-align: center;
        text-decoration: none;
    }
    
    
    
    .ownerButton, .employeeButton {
        font-family: "georgia", sans-serif;
        font-size: 24px;
        padding: 1em 2em;
        margin: 3px;
        border: 0;
        outline: 0;
        color: #000000;
        background-color: #2196F3;
        text-transform: uppercase;
        border-radius: 0.15em;
        box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
    
        font-weight: bold;
    
        overflow: hidden;
        position: relative;
    }
    
    .footer{
        font-family: sans-serif;
        font-weight: bold;
        font-size: 14px;
    
        position: fixed;
        left: 0;
        bottom: 0;
        width: 100%;
    
        background-color: #2196F3;
        text-align: center;
    }
    

    HTML CODE

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="UTF-8">
          <title>Belper</title>
      <link rel="stylesheet" href="style.css">
        </head>
        <body bgcolor=#4286f4>
    
            <a href="http://www.google.com" class="ownerButton">Sign in as OWNER</a>
            <a href="http://www.google.com" class="employeeButton">Sign in as EMPLOYEE</a>
    
            <a href="http://google.com" class="signUp">Dont have an account? Sign up here!</a>
    
            <div class="footer">
            <p>Copyright © 2000-2017 - Mathieu Larocque - All Rights Reserved.</p>
            </div>
    
        </body>
    </html>
    

    Image while window is large

    Image while window is small

1 个答案:

答案 0 :(得分:0)

您可以将display:block添加到样式表中的.signUp规则,以便在新行上显示该规则。

您还可以将display: inline-block添加到.ownerButton, .employeeButton规则

https://codepen.io/jbanegas/pen/xXpMKM?editors=1100

相关问题