2016-10-28 6 views
0

入力用のログインボックスの下に2つのボタンを作成しました。私はそれが反応的で絶対的な価値を使用したかったので、私はそれらを移動すると、ボタンが突然重なっています!どんな解決策ですか?ここに私のインデックスとスタイルシートは次のとおりです。2つのボタンが重なって配置されていますか? (HTML/CSS)

* { 
 
    margin: 0; 
 
    padding: 0; 
 
    box-sizing: border-box; 
 
} 
 
header { 
 
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(hero.jpeg); 
 
    background-size: cover; 
 
    background-position: center; 
 
    height: 100vh; 
 
} 
 
.login { 
 
    position: absolute; 
 
    /* Turns the the text box to absolute from static (allows free control of placement) */ 
 
    width: 100%; 
 
    max-width: 420px; 
 
    top: 30%; 
 
    left: 0px; 
 
    right: 0px; 
 
    height: auto; 
 
    font-size: 20pt; 
 
    margin: 0px auto; 
 
    padding: 15px; 
 
} 
 
#space-password { 
 
    padding-top: 20px; 
 
} 
 
html { 
 
    color: whitesmoke; 
 
    font-weight: 100; 
 
    font-family: 'Lato', 'Arial', sans-serif; 
 
    text-rendering: optimizeLegibility; 
 
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(hero.jpeg); 
 
} 
 
input { 
 
    border-radius: 50px; 
 
    height: 38px; 
 
    width: 100%; 
 
    color: aliceblue; 
 
    border: 2px solid #999; 
 
    background-color: #34495e; 
 
    box-sizing: border-box; 
 
    padding-left: 14px; 
 
    padding-right: 14px; 
 
    margin-top: 5px; 
 
    font-size: 17px; 
 
    font-family: 'Lato', 'Arial', sans-serif; 
 
} 
 
.btn:link, 
 
.btn:visited { 
 
    display: inline-block; 
 
    padding: 10px 30px; 
 
    /*This padding and border radius round border and define how big it is */ 
 
    font-weight: 300; 
 
    text-decoration: none; 
 
    border-radius: 200px; 
 
    transition: background-color 0.2s, border 0.2s, color 0.2s; 
 
    /* makes color subtly change instead of instantly. More applealing */ 
 
} 
 
.btn-full:link, 
 
.btn-full:visited { 
 
    background-color: #3498db; 
 
    /* From flat UI colors */ 
 
    border: 1px solid #3498db; 
 
    color: #fff; 
 
} 
 
.btn-ghost:link, 
 
.btn-ghost:visited { 
 
    border: 1px solid #3498db; 
 
    color: #3498db; 
 
} 
 
.btn:hover, 
 
.btn:active { 
 
    background-color: #7cbde8; 
 
} 
 
.btn-full:hover, 
 
.btn-full:active { 
 
    border: 1px solid #3498db; 
 
    /* Fixed issue of text disipearing in color and borders being different color for both full and ghost */ 
 
} 
 
.btn-ghost:hover, 
 
.btn-ghost:active { 
 
    border: 1px solid #3498db; 
 
    color: #fff; 
 
}
<!DOCTYPE> 
 
<html lan="en"> 
 

 
<head> 
 
    <link rel="stylesheet" type="text/css" href="vendors/css/normalize.css"> 
 
    <link rel="stylesheet" type="text/css" href="css/style.css"> 
 
    <link href="https://fonts.googleapis.com/css?family=Lato:300,400" rel="stylesheet"> 
 
    <title>Welcome-Sign in</title> 
 

 
</head> 
 

 
<body> 
 
    <header> 
 
    <form class="login"> 
 
     <p>Apple ID:</p> 
 
     <br> 
 
     <input type="text" name="Apple ID"> 
 
     <br> 
 
     <p id="space-password">Password:</p> 
 
     <br> 
 
     <input type="password" name="Password"> 
 
    </form> 
 
    <div> 
 
     <a class="btn btn-full" href="#">Login</a> 
 
     <a class="btn btn-ghost" href="#">Don't have an acount? Sign up!</a> 
 
    </div> 
 

 
    </header> 
 

 
</body> 
 

 
</html>

+0

なぜ、応答性を高めるには絶対位置を使用する必要があると思いますか?絶対配置されたアイテムでページを反応させることは本当に難しいでしょう。 https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries – Esko

答えて

0

はこれを試してみてください...

position:absoluteと応答性の設計の間には関係がありません。 絶対にこれを行うつもりなので、ボタンdivをフォームに配置してください。

* { 
 
    margin: 0; 
 
    padding: 0; 
 
    box-sizing: border-box; 
 
} 
 
header { 
 
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(hero.jpeg); 
 
    background-size: cover; 
 
    background-position: center; 
 
    height: 100vh; 
 
} 
 
.login { 
 
    position: absolute; 
 
    /* Turns the the text box to absolute from static (allows free control of placement) */ 
 
    width: 100%; 
 
    max-width: 420px; 
 
    top: 30%; 
 
    left: 0; 
 
    right: 0px; 
 
    height: auto; 
 
    font-size: 20pt; 
 
    margin: 0px auto; 
 
    padding: 15px; 
 
} 
 
#space-password { 
 
    padding-top: 20px; 
 
} 
 
html { 
 
    color: whitesmoke; 
 
    font-weight: 100; 
 
    font-family: 'Lato', 'Arial', sans-serif; 
 
    text-rendering: optimizeLegibility; 
 
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(hero.jpeg); 
 
} 
 
input { 
 
    border-radius: 50px; 
 
    height: 38px; 
 
    width: 100%; 
 
    color: aliceblue; 
 
    border: 2px solid #999; 
 
    background-color: #34495e; 
 
    box-sizing: border-box; 
 
    padding-left: 14px; 
 
    padding-right: 14px; 
 
    margin-top: 5px; 
 
    font-size: 17px; 
 
    font-family: 'Lato', 'Arial', sans-serif; 
 
} 
 
.btn{ 
 
    margin-top:30px; 
 
    font-size: 14px !important; 
 
} 
 
.btn:link, 
 
.btn:visited { 
 
    display: inline-block; 
 
    padding: 10px 30px; 
 
    /*This padding and border radius round border and define how big it is */ 
 
    font-weight: 300; 
 
    text-decoration: none; 
 
    border-radius: 200px; 
 
    transition: background-color 0.2s, border 0.2s, color 0.2s; 
 
    /* makes color subtly change instead of instantly. More applealing */ 
 
} 
 
.btn-full:link, 
 
.btn-full:visited { 
 
    background-color: #3498db; 
 
    /* From flat UI colors */ 
 
    border: 1px solid #3498db; 
 
    color: #fff; 
 
} 
 
.btn-ghost:link, 
 
.btn-ghost:visited { 
 
    border: 1px solid #3498db; 
 
    color: #3498db; 
 
} 
 
.btn:hover, 
 
.btn:active { 
 
    background-color: #7cbde8; 
 
} 
 
.btn-full:hover, 
 
.btn-full:active { 
 
    border: 1px solid #3498db; 
 
    /* Fixed issue of text disipearing in color and borders being different color for both full and ghost */ 
 
} 
 
.btn-ghost:hover, 
 
.btn-ghost:active { 
 
    border: 1px solid #3498db; 
 
    color: #fff; 
 
}
<!DOCTYPE> 
 
<html lan="en"> 
 

 
<head> 
 
    <link rel="stylesheet" type="text/css" href="vendors/css/normalize.css"> 
 
    <link rel="stylesheet" type="text/css" href="css/style.css"> 
 
    <link href="https://fonts.googleapis.com/css?family=Lato:300,400" rel="stylesheet"> 
 
    <title>Welcome-Sign in</title> 
 

 
</head> 
 

 
<body> 
 
    <header> 
 
    <form class="login"> 
 
     <p>Apple ID:</p> 
 
     <br> 
 
     <input type="text" name="Apple ID"> 
 
     <br> 
 
     <p id="space-password">Password:</p> 
 
     <br> 
 
     <input type="password" name="Password"> 
 
     <div> 
 
     <a class="btn btn-full" href="#">Login</a> 
 
     <a class="btn btn-ghost" href="#">Don't have an acount? Sign up!</a> 
 
    </div> 
 
    </form> 
 
    
 

 
    </header> 
 

 
</body> 
 

 
</html>

編集:これはあなたのコメントのためです。また、レスポンシブなレイアウトのためにMediaクエリを使用することをお勧めします。

* { 
 
    margin: 0; 
 
    padding: 0; 
 
    box-sizing: border-box; 
 
} 
 
header { 
 
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(hero.jpeg); 
 
    background-size: cover; 
 
    background-position: center; 
 
    height: 100vh; 
 
} 
 
.login { 
 
    position: absolute; 
 
    /* Turns the the text box to absolute from static (allows free control of placement) */ 
 
    width: 100%; 
 
    max-width: 420px; 
 
    top: 30%; 
 
    left: 0; 
 
    right: 0px; 
 
    height: auto; 
 
    font-size: 20pt; 
 
    margin: 0px auto; 
 
    padding: 15px; 
 
} 
 
#space-password { 
 
    padding-top: 20px; 
 
} 
 
html { 
 
    color: whitesmoke; 
 
    font-weight: 100; 
 
    font-family: 'Lato', 'Arial', sans-serif; 
 
    text-rendering: optimizeLegibility; 
 
    background-image: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url(hero.jpeg); 
 
} 
 
input { 
 
    border-radius: 50px; 
 
    height: 38px; 
 
    width: 100%; 
 
    color: aliceblue; 
 
    border: 2px solid #999; 
 
    background-color: #34495e; 
 
    box-sizing: border-box; 
 
    padding-left: 14px; 
 
    padding-right: 14px; 
 
    margin-top: 5px; 
 
    font-size: 17px; 
 
    font-family: 'Lato', 'Arial', sans-serif; 
 
} 
 
.btn { 
 
    margin-top: 30px; 
 
    font-size: 14px !important; 
 
} 
 
.btn:link, 
 
.btn:visited { 
 
    display: inline-block; 
 
    padding: 10px 30px; 
 
    /*This padding and border radius round border and define how big it is */ 
 
    font-weight: 300; 
 
    text-decoration: none; 
 
    border-radius: 200px; 
 
    transition: background-color 0.2s, border 0.2s, color 0.2s; 
 
    /* makes color subtly change instead of instantly. More applealing */ 
 
} 
 
.btn-full:link, 
 
.btn-full:visited { 
 
    background-color: #3498db; 
 
    /* From flat UI colors */ 
 
    border: 1px solid #3498db; 
 
    color: #fff; 
 
} 
 
.btn-ghost:link, 
 
.btn-ghost:visited { 
 
    border: 1px solid #3498db; 
 
    color: #3498db; 
 
} 
 
.btn:hover, 
 
.btn:active { 
 
    background-color: #7cbde8; 
 
} 
 
.btn-full:hover, 
 
.btn-full:active { 
 
    border: 1px solid #3498db; 
 
    /* Fixed issue of text disipearing in color and borders being different color for both full and ghost */ 
 
} 
 
.btn-ghost:hover, 
 
.btn-ghost:active { 
 
    border: 1px solid #3498db; 
 
    color: #fff; 
 
} 
 
.btns { 
 
    position: absolute; 
 
     /* Turns the the text box to absolute from static (allows free control of placement) */ 
 
     width: 100%; 
 
     top: 300px; 
 
     left: 15%; 
 
     right: 0px; 
 
     height: auto; 
 
     font-size: 14pt; 
 
     margin: 0px auto; 
 
     padding: 15px; 
 
}
<!DOCTYPE> 
 
<html lan="en"> 
 

 
<head> 
 
    <link rel="stylesheet" type="text/css" href="vendors/css/normalize.css"> 
 
    <link rel="stylesheet" type="text/css" href="css/style.css"> 
 
    <link href="https://fonts.googleapis.com/css?family=Lato:300,400" rel="stylesheet"> 
 
    <title>Welcome-Sign in</title> 
 

 
</head> 
 

 
<body> 
 
    <header> 
 
    <form class="login"> 
 
     <p>Apple ID:</p> 
 
     <br> 
 
     <input type="text" name="Apple ID"> 
 
     <br> 
 
     <p id="space-password">Password:</p> 
 
     <br> 
 
     <input type="password" name="Password"> 
 

 
    </form> 
 
    <div class="btns"> 
 
     <a class="btn btn-full" href="#">Login</a> 
 
     <a class="btn btn-ghost" href="#">Don't have an acount? Sign up!</a> 
 
    </div> 
 

 
    </header> 
 

 
</body> 
 

 
</html>

+0

これは少し役に立ちませんでしたが、あなたのご意見をお寄せいただきありがとうございます。私が言ったように、私がそうするとき、ボタンは重なります。両方のボタンを私がしたいと思う方法を欲しかった。 –

+0

@TempleNaylor今すぐチェック – Sankar

0

代わりのボタンを作成するために<button></button>タグを使用することができるボタンを作成する<a></a>タグを使用しました。これにより、ボタンの重なりを避けることができます。

<!DOCTYPE> 
    <html lan="en"> 
    <head> 
    <link rel="stylesheet" type="text/css" href="vendors/css/normalize.css"> 
    <link rel="stylesheet" type="text/css" href="css/style.css"> 
    <link href="https://fonts.googleapis.com/css?family=Lato:300,400" rel="stylesheet"> 
    <title>Welcome-Sign in</title> 

</head> 
<body> 
    <header> 
     <form class="login"> 
      <p>Apple ID:</p><br> 
      <input type="text" name="Apple ID"><br> 
      <p id="space-password">Password:</p><br> 
      <input type="password" name="Password"> 
     </form> 
     <div> 
      <button class="btn btn-full" >Login</button> 
      <button class="btn btn-ghost">Don't have an acount? Sign up!  </button> 
     </div> 

    </header> 

</body> 
+0

これはどのように役立ちますか?それはまだ同じ私のインデックスコードです。 –

関連する問題