我編寫了這段代碼,以便了解下面代碼的邊距,填充和位置。問題在這些/ * * /之間。再次感謝。HTML和body標籤的邊距,填充,高度和寬度
<!DOCTYPE html>
<html>
<head>
<style>
html{
width:auto; /* Does auto will apply the background-color automatically to the display screen */
height:100%; /* 100% means 100% of the display browser??*/
margin-left:1%; margin-right:1%; /*does changing the value of the margin will change anything in the page*/
margin-top:1%;margin-bottom:1%;
padding-left:1%;padding-right:1%;
padding-top:1%;Padding-bottom:0%;
border: 1px solid black;
background-color: red;
}
body{
background-color: #00FF00;
width:50%; /* does it means 50% of the width stated above in the html (auto)*/
height:50%; /*does it means 50% of the height of the display browser or we have to add the padding-top(1%) in html*/
position: fixed;
top: 25%; /* does it mean that the body is shifted to below 25% of it's heigh or 25% of the display browser? */
left:25%; /* what is the different if i give 0% to left and i changed the margin-left value to 25%*/
border: 2px solid black ;
margin-top: 0px;
margin-left: 0px;}
header{width:50%;height:auto;
top: 25%;left:25%; /* what does it mean here the value given to top and left??*/
border: 2px solid black ;
margin-top: 10%;
margin-left: 25%;}
h1{margin: 5px; color: blue;}
</style>
</head>
<body>
<header>
<h1> MY First webpage </h1>
</header>
</body>
</html>
我很困惑的是如何改變位置和身體的大小(寬度,高度,邊距,填充...),以使其位於顯示屏幕的中心。它在屏幕的左側和右側工作,但是當涉及到頂部和底部時,我無法使其完全位於顯示屏的中心。 – AmerHamze
試試這個http://zerosixthree.se/vertical-align-anything- with-just-3-line-of-css/ –
@AmerHamze你可以提供你的HTML給出一個想法,也可以證明你目前使用的任何'.css'代碼。這可能有幫助 – murday1983