我正在尝试在.container类左右放置15px填充图像
答案 0 :(得分:1)
将background-color
添加到您的容器中,并将row
div放入其中。您将看到外观,就像填充是灰色的。
.container{
background-color: grey;
height:100px;
}
.inner-row{
height: 100px;
background-color: red;
margin: 0px 10px 0px 10px;
}

<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="container">
<div class="inner-row"></div>
&#13;
答案 1 :(得分:0)
这是你的期望吗?希望它有用。
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.yourImage {
padding-left: 15px;
padding-right: 15px;
}
</style>
</head>
<body>
<div class="container">
<img src="http://www.webclasses.in/wp-content/uploads/2015/08/HTML.jpg" class="yourImage" />
</div>
</body>
</html>
&#13;
答案 2 :(得分:0)
在容器上给出额外的Class然后覆盖bootstrap css
例如: 的 HTML 强>
<div class="container container-custom">
...
</div>
<强> CSS 强>
.container.container-custom
{
padding:0 5px;
}