我正在爲自己製作一個簡單的網站。當我在瀏覽器中打開網站並減少瀏覽器橫向寬度時,主體/白色矩形將從屏幕上消失。我如何防止這種情況發生?如何防止身體脫離屏幕?
而且,隨意點在我的代碼的任何缺陷/問題。我是網絡開發新手,需要儘可能多的批評。
html {
background-image: url("bg.jpg");
padding: 150px;
background-repeat: no-repeat;
background-size: 100% 100%;
}
h1 {
line-height: 15px;
text-align: center;
font-weight: 600;
color: rgba(61, 61, 61, 0.7);
}
h3 {
line-height: 0px;
text-align: center;
font-weight: 100;
color: rgba(61, 61, 61, 0.7);
}
hr {
border: 0;
color: red;
border-bottom: 1px solid rgba(168, 168, 168, 0.92);
width: 320px;
}
p {
text-align: center;
}
body {
padding: 25px;
max-width: 400px;
min-width: 400px;
height: 200px;
font-family: "Courier New", Courier, monospace;
background: #fafafa;
margin: auto;
border-radius: 3px;
box-shadow: 0px 0px 90px rgba(58, 58, 58, 0.71);
opacity: 0.95;
position: static;
}
footer {
margin-top: 45px;
opacity: 0.5;
}
<html lang="en">
<head>
<meta charset="utf 8" />
<title>JOSH BAKOS</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<header>
<h1>JOSH BAKOS</h1>
<h3>STUDENT</h3>
</header>
<hr>
<p>I am a Java developer and a future Software Engineering Student @ UOIT.</p>
<p>
<br><a href="https://twitter.com/jzbakos" target="_blank">Twitter</a> • <a href="http://stackoverflow.com/users/6383960/jzbakos" target="_blank">StackOverflow</a> • <a href="https://github.com/jzbakos" target="_blank">Github</a>
</p>
<footer>
<p>© Josh Bakos</p>
</footer>
</body>
</html>
非常感謝。快速提問:對於卡片/白色矩形,我應該將所有這些放在一個div中,還是隻放在body中? – jxshu
挺好,年輕人 – fxm