css - bootstrap 文本和图像在中间对齐

标签 css image twitter-bootstrap text

<分区>

在 bootstrap 中有没有办法:

enter image description here

所以我希望文本和图像位于页面的中央。 右边是文本右对齐,左边是图像 我尝试过使用 div,然后尝试使用表格,但均未成功。

我试过:

<img src="your-image/path-here.jpg" class="img-responsive center-block" />

我的代码:

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <img style='float:left;width:200px;height:200px; margin-right:10px;' src="img/bootstrap.jpg" />
            <p>Bootstrap, a sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.</p>
        </div>
    </div>

编辑 文本应在图像中间对齐,并且两者都应居中。

最佳答案

试试这个——

使用 class="img-responsive pull-right " 进行图像对齐,使用 class="text-left" 进行文本对齐。

@media only screen and (min-width : 320px) {

}

/* Extra Small Devices, Phones */ 
@media only screen and (min-width : 480px) {
#text-left {
padding-top: 15%;

}
}

/* Small Devices, Tablets */
@media only screen and (min-width : 768px) {
#text-left {
padding-top: 25%;

}

}

/* Medium Devices, Desktops */
@media only screen and (min-width : 992px) {
#text-left {
padding-top: 30%;

}

}

/* Large Devices, Wide Screens */
@media only screen and (min-width : 1200px) {
#text-left {
padding-top: 35%;

}

}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
          <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
           <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
           <style type="text/css">
            
           </style>
           </head>
           <body>
          <div class="container">
    <div class="row">
        <div class="col-md-12">
            <img class="img-responsive pull-right " style="width:200px;height:200px;" src="https://cdn.pixabay.com/photo/2016/02/19/15/46/dog-1210559_960_720.jpg" />
            <p id="text-left" class="text-left">Bootstrap, a sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.</p>
        </div>
    </div>
  </body>
  </html>

关于css - bootstrap 文本和图像在中间对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42418409/

相关文章:

javascript - 添加 Bootstrap 工具提示会修改元素本身的样式——如何阻止这种情况发生?

php - 告诉从哪里包含了 .php 文件?

c++ - 在 C++ 中填充图像周围黑色边框的最有效方法

javascript - chrome 不渲染 gif 背景图片

ios - 在 iOS 中快速绘制大图像的一小部分

image - 计算图像的像素长度

html - bootstrap 3 中的 float 框

html - 悬停放大时的跨度和图像大小

javascript - 将 div 添加到幻灯片轮播

html - wordpress 整个站点内容向右移动,需要再次居中