Html 表单左侧的边距在右侧创建额外的空白
我已经使用marginleft属性定位了表单,但是它添加了一个水平滚动条,在页面的右侧创建了额外的空白。下面是我在上面使用的CSSHtml 表单左侧的边距在右侧创建额外的空白,html,css,Html,Css,我已经使用marginleft属性定位了表单,但是它添加了一个水平滚动条,在页面的右侧创建了额外的空白。下面是我在上面使用的CSS .form { width:100%; margin-left:35%; box-sizing: border-box; } 我怎样才能去掉右边的空白 编辑: <!DOCTYPE html> <html> <head> <title>Forms</title> &l
.form {
width:100%;
margin-left:35%;
box-sizing: border-box;
}
我怎样才能去掉右边的空白
编辑:
<!DOCTYPE html>
<html>
<head>
<title>Forms</title>
<script type="text/javascript" src="../js/script.js"></script>
<link rel="stylesheet" type="text/css" href="../css/forms.css">
</head>
<body id="formbody">
<h3 class="formheader">create a new account</h3>
<form action="#" target="_self" class="form">
<input type="text" name="firstname" class="input text" placeholder="firstname">
<input type="text" name="lastname" class="input text" placeholder="lastname">
<div class="genderholder">
<h4 class="genderheader">Gender</h4>
<label class="genderlabel">male <input type="radio" name="gender" class="input radio"></label>
<label class="genderlabel">female <input type="radio" name="gender" class="input radio"></label>
<label class="genderlabel">others <input type="radio" name="gender" class="input radio"></label>
</div>
<select class="input country">
<option>Select a Country</option>
</select>
<div class="holder">
<h4 class="dobheader">Date of birth</h4>
<select id="day" class="input day">
<option>Day</option>
</select>
<select class="input month">
<option>Month</option>
</select>
<select class="input year">
<option>Year</option>
</select>
</div>
<input type="email" name="email" class="input email" placeholder="email">
<input type="submit" name="signup" value="sign up" class="input submit">
</form>
</body>
</html>
形式
创建新帐户
性别
男性
女性
其他
选择一个国家
出生日期
白天
月
年
试试这段代码
.form {
max-width:100%;
min-width:100%;
margin-left:35%;
overflow-x:hidden;
box-sizing: border-box;
}
.body{
max-width: 100%;
}
我假设您正在尝试将表单放在页面的中心位置。如果是这样,这就是解决办法
.form{
宽度:适合的内容;
保证金:0自动;
框大小:边框框;
}
身体{
最大宽度:100vw;
}
形式
创建新帐户
性别
男性
女性
其他
选择一个国家
出生日期
白天
月
年
请发布您的htmlcode@SaiManoj添加了html代码。我已经发布了答案。看一看,可能有一些内部的形式,推动额外的空间。你能为所有其他类/css提供小提琴或钢笔吗?这没有任何区别。是的,我试图使用margin:auto;但它不起作用,这就是为什么我使用左边距。不知怎的,你的办法奏效了。谢谢