引导文本和图像在中间对齐

时间:2017-02-23 14:23:13

标签: css image twitter-bootstrap text

引导程序中有没有办法:

enter image description here

所以我希望文本和图像位于页面的中心。 右侧是文本右对齐,左侧是图像 我已尝试使用div,然后使用table而没有成功。

我试过了:

<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>

我的代码:

    $this->data['ac_all_stores'] = $this->load->controller('module/store');

编辑文字应在图片中间对齐,两者都应位于中心。

3 个答案:

答案 0 :(得分:2)

尝试 -

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

&#13;
&#13;
@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%;

}

}
&#13;
<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>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

您是否尝试过使用bootstrap的网格系统?这样的事情可能是你的解决方案:

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

答案 2 :(得分:1)

试试这个

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