通过使用Bootstrap,我尝试在它们的右侧创建3个图像和文本的行。如果使用移动(小型)设备浏览,我希望每行只有一张图片,文字在右边。图像可以是不同的大小,但我希望他们显示在相同的大小(内联风格现在)。目前,它在大型设备上看起来还可以,但当缩小视区时,包装是关闭的。而不是所有的列都在另一列下,而是错误地换行。如果我去掉图像上的“向左拉”,它们会正确换行,但文本会在图像下方。我怎么才能在这里做我想做的事呢?
我当前的html:
<div class="row">
<div class="col-sm-4">
<img src="http://lorempixel.com/300/200/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 1</h3>
<p>Text 1 is cool text</p>
</div>
<div class="col-sm-4">
<img src="http://lorempixel.com/400/200/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 2</h3>
<p>Text 2 is also cool text</p>
</div>
<div class="col-sm-4">
<img src="http://lorempixel.com/800/800/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 3</h3>
<p>Text 3 is also very cool text</p>
</div>
</div>发布于 2017-04-06 16:34:01
这就是你要找的吗?
<div class="row">
<div class="col-md-4 col-sm-12">
<img src="http://lorempixel.com/300/200/" class="img-rounded col-md-2 col-sm-6" style="margin-right:10px;width:100px;height:100px;">
<div class="col-sm-6">
<h3>Header 1</h3>
<p>Text 1 is cool text</p>
</div>
</div>
<div class="col-md-4 col-sm-12">
<img src="http://lorempixel.com/400/200/" class="img-rounded col-md-2 col-sm-6" style="margin-right:10px;width:100px;height:100px;">
<div class="col-sm-6">
<h3>Header 2</h3>
<p>Text 2 is also cool text</p>
</div>
</div>
<div class="col-md-4 col-sm-12">
<img src="http://lorempixel.com/800/800/" class="img-rounded col-md-2 col-sm-6" style="margin-right:10px;width:100px;height:100px;">
<div class="col-sm-6">
<h3>Header 3</h3>
<p>Text 3 is also very cool text</p>
</div>
</div>
</div>发布于 2017-04-06 18:42:56
似乎我必须将我的专栏包装在clearfix类的另一个div中:
<div class="row">
<div class="col-sm-4">
<div class="clearfix content-heading">
<img src="http://lorempixel.com/300/200/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 1</h3>
<p>Text 1 is cool text</p>
</div>
</div>
<div class="col-sm-4">
<div class="clearfix content-heading">
<img src="http://lorempixel.com/400/200/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 2</h3>
<p>Text 2 is also cool text</p>
</div>
</div>
<div class="col-sm-4">
<div class="clearfix content-heading">
<img src="http://lorempixel.com/800/800/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 3</h3>
<p>Text 3 is also very cool text</p>
</div>
</div>
</div>发布于 2017-04-09 23:27:32
如果您不是在寻找引导列断点,并且仍然在寻找一些东西,那么可以尝试使用引导媒体断点。
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row">
<div class="col-sm-4 row1" >
<img src="http://lorempixel.com/300/200/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 1</h3>
<p>Text 1 is cool text</p>
</div>
<div class="col-sm-4 row2">
<img src="http://lorempixel.com/400/200/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 2</h3>
<p>Text 2 is also cool text</p>
</div>
<div class="col-sm-4 row3">
<img src="http://lorempixel.com/800/800/" class="pull-left img-rounded" style="margin-right:10px;width:100px;height:100px;">
<h3>Header 3</h3>
<p>Text 3 is also very cool text</p>
</div>
</div>
</body>
</html>使用媒体断点的CSS:
使用最大宽度的
<style type="text/css">
/* Extra Small Devices, Phones */
@media only screen and (max-width : 768px) {
/* YOUR CODE HERE|EXAMPLE CODES*/
body{
background-color: black;
}
.row2{
display: none;
}
.row3{
display:none;
}
}
/* Small Devices, Tablets */
@media only screen and (max-width : 992px) {
/* YOUR CODE HERE|EXAMPLE CODES*/
body{
background-color: blue;
}
.row3{
display:none;
}
}
/* Medium Devices, Desktops */
@media only screen and (max-width : 1200px) {
/* YOUR CODE HERE|EXAMPLE CODES| SET HERE WHAT YOU NEED TO HIDE OR ANYTHING*/
body{
background-color: green;
}
}
/* Large Devices, Wide Screens
USE DEFAULT
*/
</style>使用最小宽度的
<style type="text/css">
/* Extra Small Devices, Phones */
@media only screen and (min-width : 480px) {
/* YOUR CODE HERE|EXAMPLE CODES*/
body{
background-color: black;
}
}
/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
/* YOUR CODE HERE|EXAMPLE CODES*/
body{
background-color: blue;
}
}
/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
/* YOUR CODE HERE|EXAMPLE CODES| SET HERE WHAT YOU NEED TO HIDE OR ANYTHING*/
body{
background-color: green;
}
}
/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
/* YOUR CODE HERE*/
}
</style>https://stackoverflow.com/questions/43249405
复制相似问题