[英]how to make this html and css code as responsive web design
如何將以下 CSS 代碼轉換為響應式網頁設計。 我只做桌面設計我希望它作為一個響應式網站。 我嘗試了媒體查詢,但它看起來不像響應式設計。 所以我做了哪些改變來制作響應式網頁設計。
<html> <head> <title>LogIn</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <style> *{ box-sizing: border-box; } body{ background-image: url('login_background.jpg'); background-repeat: no-repeat; background-size: cover; } .wrapper{ background-color: white; overflow: hidden; display: block; height:500px; width: 400px; margin: auto; margin-top: 100px; } h1{ color:rgb(19, 211, 211); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin-top: 10px; margin-bottom: 10px; text-align: center; text-transform: uppercase; } .input{ display: block; margin:auto; } .text{ width: 390px; height:50px; margin:30px auto 30px auto; border: none; border-bottom: 1px solid rgb(19, 211, 211); } .input[placeholder]{ text-align: center; color:rgb(19, 211, 211); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: medium; } .text:focus{ text-align: center; color:rgb(19, 211, 211); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: medium; border-bottom: 1px solid rgb(19, 211, 211); outline: none; } .button{ margin:30px auto 30px auto; width: 100px; height: 40px; color:rgb(19, 211, 211); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: medium; font-weight: bold; } .button:hover{ background-color:rgb(19, 211, 211) ; margin:30px auto 30px auto; width: 100px; height: 40px; color:white; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: medium; font-weight: bold; border:1px solid white; } .ref{ margin:30px auto 30px 5px; color:rgb(19, 211, 211); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: medium; font-weight: bold; text-decoration: none; } @media only screen and (max-width: 768px){ [class="wrapper"]{ width:100%; } } </style> <body> <div class="wrapper"> <form id='form1'> <h1>LogIn</h1> <input type="text" class="input text" placeholder="UserName"> <input type="password" class="input text" placeholder="Password"> <a href="#" class="ref">Forgot Password</a> <input type="button" class="input button" value="LogIn"> <a href="#" class="ref">Don't Have Account? Sign Up</a> </form> </div> </body> </html>
如何將以下 CSS 代碼轉換為響應式網頁設計。 我只做桌面設計我希望它作為一個響應式網站。 我嘗試了媒體查詢,但它看起來不像響應式設計。 所以我做了哪些改變來制作響應式網頁設計。
這里有個問題...
可能的解決方案之一:
<html>
<head>
<title>LogIn</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style>
*{
box-sizing: border-box;
}
body{
background-image: url('login_background.jpg');
background-repeat: no-repeat;
background-size: cover;
}
.wrapper{
background-color: white;
overflow: hidden;
display: block;
height:500px;
width: 400px;
margin: auto;
margin-top: 100px;
}
h1{
color:rgb(19, 211, 211);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin-top: 10px;
margin-bottom: 10px;
text-align: center;
text-transform: uppercase;
}
.input{
display: block;
margin:auto;
}
.text{
width: 390px;
height:50px;
margin:30px auto 30px auto;
border: none;
border-bottom: 1px solid rgb(19, 211, 211);
}
.input[placeholder]{
text-align: center;
color:rgb(19, 211, 211);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: medium;
}
.text:focus{
text-align: center;
color:rgb(19, 211, 211);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: medium;
border-bottom: 1px solid rgb(19, 211, 211);
outline: none;
}
.button{
margin:30px auto 30px auto;
width: 100px;
height: 40px;
color:rgb(19, 211, 211);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: medium;
font-weight: bold;
}
.button:hover{
background-color:rgb(19, 211, 211) ;
margin:30px auto 30px auto;
width: 100px;
height: 40px;
color:white;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: medium;
font-weight: bold;
border:1px solid white;
}
.ref{
margin:30px auto 30px 5px;
color:rgb(19, 211, 211);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: medium;
font-weight: bold;
text-decoration: none;
}
@media only screen and (max-width: 768px){
[class="wrapper"]{
width:100%;
text-align: center;
}
.text{
max-width: 300px;
}
.wrapper {
margin-top: 20px; height: auto;
}
}
</style>
<body>
<div class="wrapper">
<form id='form1'>
<h1>LogIn</h1>
<input type="text" class="input text" placeholder="UserName">
<input type="password" class="input text" placeholder="Password">
<a href="#" class="ref">Forgot Password</a>
<input type="button" class="input button" value="LogIn">
<a href="#" class="ref">Don't Have Account? Sign Up</a>
</form>
</div>
</body>
... 可以解決這個問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.