这是我在HTML中的代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Selection</title>
<link rel="stylesheet" href="style.css">
</head>
<body >
<div id="container" >
<form action="http://localhost:8084/CBGS/Allocate" method="Get">
<h1>College EXAM SECTION</h1>
<div id="sem">Semester:
<select name="sem">
<option value="3" >Sem3</option>
<option value="4">Sem4</option>
<option value="5">Sem5</option>
<option value="6">Sem6</option>
</select>
</div>
<div id="branch">Branch:
<select name="branch">
<option value="IT" >IT</option>
<option value="COMP">COMP</option>
<option value="MECH">MECH</option>
<option value="CIVIL">CIVIL</option>
<option value="EXTC">EXTC</option>
</select>
</div>
<div id="exam">
<input type="radio" name="exam" value="R" />REGULAR<br>
<input type="radio" name="exam" value="K"/>KT
</div>
<div id="numberstudent">
No of student
<input type="number" name="noOfStudent" min="1" max="100">
</div>
< input type ="submit">
</form>
</div>
</body>
</html>
和样式.css是
body
{
margin: 0px auto;
width:700px;
//margin:0 auto;
//margin-left:50px;
font-family:Arial, Helvetica, sans-serif;
font-size:100%;
color: white;
line-height:1em;
background-image: url("image/tail-middle.jpg");
background-repeat: repeat-y;
}
#container
{
background:url(image/newsletter-bg.gif) ;
display: block;
border-radius:10px;
// border:10px solid ;//#EE872A;
//background-color: yellow;
width:600px;
margin-left: auto;
margin-right: auto;
margin-top: 10%;
padding: 20px;
}
h1{
//color: black;
margin-left: 20px;
}
#sem , #branch, #exam,#numberstudent {
display: block;
//color: blueviolet;
}
#branch,#sem {
float: left;
}
#exam{
clear: both;
}
#numberstudent{
margin-left: auto;
margin-right: auto;
}
但是这里保证金:0自动不起作用,因为我的图像没有向中心移动,即使我使用保证金 - 左边它也不起作用,我的代码中有什么颜色,任何建议都是最受欢迎的
答案 0 :(得分:0)
----------
body {
margin: 0px auto;
width: 700px;
font-family: Arial, Helvetica, sans-serif;
font-size: 100%;
color: white;
line-height: 1em;
background-image: url("image/tail-middle.jpg") #ccc;
background-repeat: repeat-y;
background-position: 50% 0;
}
.wrapper{
width:100%;
background-image:url("http://www.corelangs.com/html/html.png");
background-repeat:no-repeat;
}
#container {
background: url(image/newsletter-bg.gif);
display: block;
border-radius: 10px;
/*border:10px solid ;//#EE872A;
background-color: yellow;*/
width: 600px;
margin-left: auto;
margin-right: auto;
margin-top: 10%;
padding: 20px;
}
h1 {
//color: black;
margin-left: 20px;
}
#sem,
#branch,
#exam,
#numberstudent {
display: block;
//color: blueviolet;
}
#branch,
#sem {
float: left;
}
#exam {
clear: both;
}
#numberstudent {
margin-left: auto;
margin-right: auto;
}
<html>
<head>
</head>
<body>
<div class="wrapper">
<div id="container">
<form action="http://localhost:8084/CBGS/Allocate" method="Get">
<h1>College EXAM SECTION</h1>
<div id="sem">Semester:
<select name="sem">
<option value="3">Sem3</option>
<option value="4">Sem4</option>
<option value="5">Sem5</option>
<option value="6">Sem6</option>
</select>
</div>
<div id="branch">Branch:
<select name="branch">
<option value="IT">IT</option>
<option value="COMP">COMP</option>
<option value="MECH">MECH</option>
<option value="CIVIL">CIVIL</option>
<option value="EXTC">EXTC</option>
</select>
</div>
<div id="exam">
<input type="radio" name="exam" value="R" />REGULAR
<br>
<input type="radio" name="exam" value="K" />KT
</div>
<div id="numberstudent">
No of student
<input type="number" name="noOfStudent" min="1" max="100">
</div>
< input type="submit">
</form>
</div>
</div>
</body>
</html>
答案 1 :(得分:0)
尝试在css中添加以下内容:
body{margin: 0px auto !important; width:700px;}
答案 2 :(得分:-1)
您是否尝试在正文之前使用星号(*)选择器并将边距设置为0? 例如:
* {
margin: 0;
}
答案 3 :(得分:-1)
尝试在您的CSS中添加text-align: center;
。即使它不是文本,也经常需要这个属性。