css - Bootstrap col-md-4 h2 not centering on mobile -


i using rails make simple shopping app displays list of products. on mobile view when product stack 1 long list instead of row of 3, product h2 tags not centering, , floating right reason. first h2 tag centers fine, rest float right , not center correctly. i've tried related css can think of

  • text-align: center;
  • margin-bottom: 10px;
  • text-center
  • thinking might floating because close together?

here html , css

<div class="row text-center">         <% @products.each |product| %>           <div class="product col-md-4 text-center">            <h2><%= link_to product.name, product_path(product) %></h2>             <%= link_to image_tag(product.image_file_name, product_path(product), :class => 'img-responsive' %>             <div class="product-info">                 <div class="product-info-left"><%=product.descrip %></div>                 <div class="product-info-right">$<%=product.price %></div>             </div>           </div>         <% end %>     </div> 

css

@media(max-width:768px) {     .product-page, .product-show {         padding-top: 2px;     }      .product-info-right, .product-info-left {         margin-bottom: 10 !important;     }      .product > h2{         text-align: center !important;     } }      .product-info-left {     float: left;     width: 50%;     font-family: 'pacifico', cursive;      font-size: 15px; }  .product-info-right {     float: right;     width: 50%;     font-family: 'oswald', sans-serif; }  .product img {     height: 200px !important;     width: 250px !important; }  .product h2 {     font-family: 'oswald', sans-serif;     font-size: 24px; }  .product > h2 > {     color: black !important;     border-bottom: 1px solid #1e9b69; } 

my thinking maybe happening because elements close , being floated right default, have tried correct behavior through margin, float, , text-align, , still nothing. or suggestions of might doing wrong appreciated.

in html have h2 in styles try center h1 on line

.product > h1{     text-align: center !important; } 

there has

.product > h2 {     text-align: center !important; } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -