How to center div with col-md-6?

前端 未结 3 971
深忆病人
深忆病人 2021-01-03 20:09

I need to display in the center the div with class=\"col-md-6\"

This is the code, that display me the timer at the left I nee to display time in the cen

相关标签:
3条回答
  • 2021-01-03 20:39

    As I see you are using wordpress. And the code you placed is not end properly. If I'm not wrong there is also other part of col-md-6 you have in the row. So easily you can set the time in center .upcoming-campaign { text-align: center; } adding this. If any Question ask me in comment.

    .upcoming-campaign {
      text-align: center;
    }
    <head>
    
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    
    </head>
    
    <body>
      <div class="container">
       <div class="row">
        <div class="wpb_column vc_column_container col-md-6">
          <div class="vc_column-inner ">
            <div class="wpb_wrapper">
              <div class="event-wrapper featured-event  ">
    
                <!-- the loop -->
    
                <div class="upcoming-campaign">
                  <img width="555" height="400" src="http://andrejceccoli.com/wp-content/uploads/2016/10/elezioni_sfondo.jpg" class="img-responsive wp-post-image" alt="Elezioni Politiche">
                  <div class="campaign-scoop">
                    <h3 class="title"><a href="http://trendytheme.net/demo2/wp/nominee/onepage/event/election-campaign/">Elezioni Politiche</a></h3>
    
                    <span class="start-date">Inizia il: <span class="colored">20 Nov 2016</span></span>
    
                    <div class="countdown-wrapper">
                      <ul class="countdown list-inline" data-countdown="2016-11-20">
                        <li><span class="days">38<span><p>Days</p></span></span>
                        </li>
                        <li><span class="hours">07<span><p>Hour</p></span></span>
                        </li>
                        <li><span class="minutes">48<span><p>Minutes</p></span></span>
                        </li>
                        <li><span class="second">12<span><p>Second</p></span></span>
                        </li>
                      </ul>
    
                    </div>
    
                    <address>
                  <i class="fa fa-map-marker"></i>San Marino                            
               </address>
    
               
    
     <span class="event-duration colored"><i class="fa fa-clock-o"></i>08:00 AM - 23:00 PM</span>
                  </div>
                  <!-- .campaign-scoop -->
                </div>
                <!-- .upcoming-campaign -->
    
                <!-- end of the loop -->
    
    
              </div>
              <!-- end of event-wrraper -->
            </div>
            <!-- end of wpb-wrapper -->
          </div>
          <!-- end of vc_colum-inner -->
        </div>
        <!-- end of col-md-6 [1] -->
    
        <div class="wpb_column vc_column_container col-md-6">
          <div class="vc_column-inner ">
            <div class="wpb_wrapper">
    
    
            </div>
            <!-- end of wpb-wrapper -->
          </div>
          <!-- end of vc_colum-inner -->
        </div>
        <!-- end of col-md-6 [2] -->
    
      </div>
      <!-- end of Row -->
    </div>
    <!-- end of the Container -->
    
    </body>

    0 讨论(0)
  • 2021-01-03 20:40

    Just add "float:none;margin:auto;" to your div style like this :

    <div class="col-lg-6" style="float:none;margin:auto;">
       .....
    </div>
    

    Hope to be useful ;)

    0 讨论(0)
  • 2021-01-03 20:57

    Bootstrap 3

    Add the col-md-offset-3 class that will offset by 3 columns, given that Bootstrap has a 12-column grid this will put a col-md-6 element right in the center.

    Documentation reference on offsets.

    Bootstrap 4

    Use offset-3 or mx-auto to center a col-md-6 column

    0 讨论(0)
提交回复
热议问题