php - 使用 bootstrap 将文本和图像并排对齐

标签 php html css image

如何让图像在文本和按钮旁边居中?图片在左边,因为我放置了 float:left,但如果我不放置它,图片会居中,但文本会在它下面。使用 Bootstrap 3.3.7

enter image description here

 <div class="container">
    <div class="row">        
        <div class="col-md-4 col-xs-12">
            <img src="images/hand.jpg"class="img-responsive"/>
        </div>
        <p>Some text heree</p>
        <h1>Title</h1>      
        <p>Some text here </p>
        <button>CTA</button>
   </div>
</div> 

CSS

<style>
.row img{
    width:300px;
    float:left;
    height:auto !important;
}
.container{
    text-align: center !important;
    width:100%;
}
.row{
    margin-top:0;
}
p{
    font-family:"Fjalla One", sans-serif !important;
    font-size: 20px;
}
h1{
font-family: 'Knewave', cursive;
font-size:40px;
color:black;
margin:0 !important;
padding: 0!important;
}
</style>

最佳答案

您应该使用 Bootstrap 类而不是您自己的 css。因为他们办过很多案子,css也很稳定。这是适合您的纯引导解决方案。

我用了另一张图片,你的图片会很合适。

注意:如果您遇到任何问题,请告诉我。

p{
    font-family:"Fjalla One", sans-serif !important;
    font-size: 20px;
}
h1{
  font-family: 'Knewave', cursive;  
  font-size:40px;
  color:black;
  margin:0 !important;
  padding: 0!important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
    <div class="row">        
        <div class="col-md-6 col-xs-6 text-right">
            <img src="https://code.google.com/images/developers.png" style="height: 80px;"/>
        </div>
        <div class="col-md-6 col-xs-6">
          <p>Some text heree</p>
          <h1>Title</h1>      
          <p>Some text here </p>
          <button>CTA</button>
        </div>
   </div>
</div>

关于php - 使用 bootstrap 将文本和图像并排对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51668266/

相关文章:

php - 无法在我的 ubuntu 上进行 Xdebug var_dump 格式化工作

javascript - 如何以 HTML 格式输出 XML

javascript - 如何根据另一个部分的计算宽度设置一个部分的宽度?

javascript - 如何在 AngularJS 中单击按钮显示所有元素的计数?

html - 如何使用 *ngFor 在 Angular 中显示数据行

php - Facebook API(Javascript): Posting to a friendlist

javascript - 解析句子并提取转换值

php - 使用 Varnish 时如何记录网站的页面浏览量

javascript - 为什么 navigator.geolocation.getCurrentPosition 在 IE 11 上不起作用

html - 是否有可能在CSS中获取另一个元素的值