【发布时间】:2017-05-15 04:15:12
【问题描述】:
在用户在表单中提交他们的位置后,我正在尝试将背景图像附加到我的 jumbotron。 URL 工作正常,但附加的图像永远不会在 jumbotron 中作为背景结束。如有任何帮助,我将不胜感激。
我的 HTML:
<div class="jumbotron">
<div class="container-fluid text-center ">
<h3 class="greeting">Where would you like to move?</h1>
<form id="form-container" class="form-container">
<label for="street">Street: </label><input type="text" id="street" value="">
<label for="city">City: </label><input type="text" id="city" value="">
<p><button class ="btn btn-success btn-md "id="submit-btn">Submit</button></p>
</form>
</div>
我的 CSS:
.jumbotron {
height: 400px;
}
.bgimg {
width: 100%;
opacity: 0.9;
}
我的 JavaScript 代码:
var street = $("#street").val();
var city = $("#city").val();
var fullLocation = street +", " + city;
var googleUrl = '"https://maps.googleapis.com/maps/api/streetview?size=1000x400&location=' + fullLocation + '"';
$(".jumbotron").append("<img class='bgimg' src=" +googleUrl+ ">");
【问题讨论】:
-
HTML 格式不正确:2 个起始 div,但只有一个结尾(以及 user Ionut mentioned)。使用 HTML 验证器,例如推荐https://validator.w3.org/nu/。
标签: jquery css twitter-bootstrap layout