我正在尝试在我的网站中插入反馈表单。我有一个电子邮件字段和短信字段,带有一个发送按钮。所有这些都在Bootstrap行中。但是这一行的宽度比屏幕宽度要宽。我希望行适合屏幕宽度的100%。有人可以帮帮我吗?提前谢谢!
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<body>
<div class="row" id="getintouchrow" style="background-color: #1C2833;border: none;">
<div class="col-md-3"></div>
<div class="col-md-6">
<center>
<h1 style="margin-top: 100px;font-family: 'Audiowide', cursive;color: #B2BABB">Sample Text</h1>
<h5 style="font-family: 'Abel', sans-serif;color: #B2BABB">Sample Text<br></h5>
</center>
<form style="background-color: transparent">
<div class="form-group">
<input type="email" class="form-control" id="InputEmail1" placeholder="Enter email" style="background-color: rgba(0,0,0,0);border-top:none;border-radius: none;border-left: none;border-right: none;">> </div>
<div class="form-group">
<textarea class="form-control" id="Textarea" rows="3" placeholder="Type here" style="background-color: rgba(0,0,0,0);border-top:none;border-radius: none;border-left: none;border-right: none;"></textarea><br><br>
</div>
<center>
<center><a href="#" class=" contact-mission btn btn-outline-dark" style="font-size: 22px;width: 300px;outline-width: 50px;height: 50px;font-family: 'Pacifico', cursive;margin-bottom: 70px;">Send Message</a></center>
</center>
</form>
<div class="col-md-3"></div>
<div class="py-5 text-white" style="border-top-color: #1C2833">
<div class="container">
<div class="row">
<div class="col-4 col-md-1 align-self-center">
<a href="https://www.facebook.com" target="_blank">
<i class="fa fa-fw fa-facebook fa-3x text-white"></i>
</a>
</div>
<div class="col-4 col-md-1 align-self-center">
<a href="https://twitter.com" target="_blank">
<i class="fa fa-fw fa-twitter fa-3x text-white"></i>
</a>
</div>
<div class="col-4 col-md-1 align-self-center">
<a href="https://www.instagram.com" target="_blank">
<i class="fa fa-fw fa-instagram text-white fa-3x"></i>
</a>
</div>
</div>
<div class="row">
<div class="col-md-12 mt-3 text-center">
<p>© Copyright 2018 - All rights reserved.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
因为您正在使用Bootstrap。 bootstrap的结构表示所有内容都应该包含在类container
中。其后是row
,里面有列。由于行样式是:
.row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
它给出左右边距-15px,以覆盖来自父container
类的填充。因此,请将row
与container
一起打包,以获得所需的结果
有用的链接,以便更好地理解网格:
https://getbootstrap.com/docs/4.0/examples/grid/
答案 1 :(得分:0)
如果行扩展超过宽度,请确保row{border:0px;margin-right:0;margin-left:0;max-width:100%; }
答案 2 :(得分:0)
看,因为在.row中左右两侧都设置了负边距 15px。这就是为什么它的宽度大于屏幕大小,因此你可以使用 bootstrap 约定所允许的适当结构。
容器&gt;行&gt;山口强>
它将占用整个屏幕尺寸。
答案 3 :(得分:0)
使用&#34;容器流体&#34; class而不是row。
请参阅以下小提琴
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid" id="getintouchrow" style="background-color: #1C2833;border: none;">
<div class="col-md-3"></div>
<div class="col-md-6">
<center>
<h1 style="margin-top: 100px;font-family: 'Audiowide', cursive;color: #B2BABB">Sample Text</h1>
<h5 style="font-family: 'Abel', sans-serif;color: #B2BABB">Sample Text<br></h5>
</center>
<form style="background-color: transparent">
<div class="form-group">
<input type="email" class="form-control" id="InputEmail1" placeholder="Enter email" style="background-color: rgba(0,0,0,0);border-top:none;border-radius: none;border-left: none;border-right: none;">> </div>
<div class="form-group">
<textarea class="form-control" id="Textarea" rows="3" placeholder="Type here" style="background-color: rgba(0,0,0,0);border-top:none;border-radius: none;border-left: none;border-right: none;"></textarea><br><br>
</div>
<center>
<center><a href="#" class=" contact-mission btn btn-outline-dark" style="font-size: 22px;width: 300px;outline-width: 50px;height: 50px;font-family: 'Pacifico', cursive;margin-bottom: 70px;">Send Message</a></center>
</center>
</form>
<div class="col-md-3"></div>
<div class="py-5 text-white" style="border-top-color: #1C2833">
<div class="container">
<div class="row">
<div class="col-4 col-md-1 align-self-center">
<a href="https://www.facebook.com" target="_blank">
<i class="fa fa-fw fa-facebook fa-3x text-white"></i>
</a>
</div>
<div class="col-4 col-md-1 align-self-center">
<a href="https://twitter.com" target="_blank">
<i class="fa fa-fw fa-twitter fa-3x text-white"></i>
</a>
</div>
<div class="col-4 col-md-1 align-self-center">
<a href="https://www.instagram.com" target="_blank">
<i class="fa fa-fw fa-instagram text-white fa-3x"></i>
</a>
</div>
</div>
<div class="row">
<div class="col-md-12 mt-3 text-center">
<p>© Copyright 2018 - All rights reserved.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>