How To Center Div With Col-md-6? - Css - Stack Overflow
Có thể bạn quan tâm
-
- Home
- Questions
- Tags
- Users
- Companies
- Labs
- Jobs
- Discussions
- Collectives
-
Communities for your favorite technologies. Explore all Collectives
- Teams
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Try Teams for free Explore Teams - Teams
-
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about CollectivesTeams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about TeamsGet early access and see previews of new features.
Learn more about Labs How to center div with col-md-6? Ask Question Asked 8 years, 2 months ago Modified 2 years, 9 months ago Viewed 152k times 48I 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 center
<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> </div> </div> </div> </div> </div> Share Improve this question Follow edited Jan 13, 2017 at 8:53 Eldelshell 6,9408 gold badges46 silver badges64 bronze badges asked Oct 12, 2016 at 15:13 poopppoopp 1,4472 gold badges18 silver badges27 bronze badges 4- Are you using Bootstrap? – Alec von Barnekow Commented Oct 12, 2016 at 15:14
- Declare a css class like, .col-aligncenter{float: none;margin: 0 auto;} and place the .col-aligncenter after your col-md-6 – David R Commented Oct 12, 2016 at 15:16
- 1 It is already asked and answered, stackoverflow.com/questions/10088706/… – KnowGe Commented Oct 12, 2016 at 15:20
- @KnowGe the accepted answer there is bad practice and wrong. – Niels Keurentjes Commented Oct 12, 2016 at 15:25
4 Answers
Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 93Bootstrap 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
Share Improve this answer Follow edited Aug 24, 2018 at 12:35 Carol Skelly 362k91 gold badges733 silver badges645 bronze badges answered Oct 12, 2016 at 15:23 Niels KeurentjesNiels Keurentjes 41.9k9 gold badges100 silver badges137 bronze badges Add a comment | 22Just 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 ;)
Share Improve this answer Follow answered May 3, 2019 at 15:24 Ali MahmoodiAli Mahmoodi 1,16413 silver badges16 bronze badges Add a comment | 5As 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>
Share Improve this answer Follow answered Oct 12, 2016 at 17:07 Baezid MostafaBaezid Mostafa 2,7202 gold badges15 silver badges27 bronze badges Add a comment | 1In case you are wondering the answer for Bootstrap 5, you need to add justify-content-md-center beside to the DIV containing the ROW class.
Documented example here.
Share Improve this answer Follow answered Mar 1, 2022 at 8:42 SamyCodeSamyCode 1,0083 gold badges17 silver badges33 bronze badges Add a comment |Your Answer
Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Draft saved Draft discardedSign up or log in
Sign up using Google Sign up using Email and Password SubmitPost as a guest
Name EmailRequired, but never shown
Post Your Answer DiscardBy clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Not the answer you're looking for? Browse other questions tagged
or ask your own question.- The Overflow Blog
- Why do developers love clean code but hate writing documentation?
- This developer tool is 40 years old: can it be improved?
- Featured on Meta
- The December 2024 Community Asks Sprint has been moved to March 2025 (and...
- Stack Overflow Jobs is expanding to more countries
Linked
304 How can I center elements horizontally or vertically with Twitter Bootstrap? 5 center a panel on screenRelated
6 Centering .col-md-x on bootstrap 0 CSS - Bootstrap centering col-md-3 with weird results 16 Bootstrap: Centering col-md-5? 1 How do I center everything inside 2 bootstrap columns? (col-md-6 and col-md-6)? 3 How to center div within col-md-12 in bootstrap 0 Bootstrap col-md-6 align vertical centre 0 Bootstrap - center div's with col-ld-* 3 Center text in col-md-4 1 Centering li col-md-5 0 how to align content horizontally central using col-mdHot Network Questions
- What should I do if I am being guided to walk in circles?
- Is it possible to symbolically solve this polynomial system of equations and inequalities with Mathematica?
- Concatenating column vectors in a loop
- Short story about a city enclosed in an electromagnetic field
- How can I secure a magnetic door catch with a stripped screw?
- Meaning of Second line of Shakespeare's Sonnet 66
- Do I need to get a visa (Schengen) for transit?
- How to do a batch of changes in `about:config` in the Firefox?
- Is the word "boy" racist in the following situation?
- How to Speed Up the Summation of a Sequence?
- Answering student's question that is already in the upcoming exam
- Can a table of results be returned and formatted as a table in Agentforce when an Apex @InvocableMethod is used?
- Noisy environment while meditating
- Shakespeare and his syntax: "we hunt not, we"
- Must one be a researcher at a university to become an author of a research paper?
- heute Nacht = tonight or last night?
- Permanent night on a portion of a planet
- What does the hypothesis "EPR=ER" claim?
- 2010s-era Analog story referring to something like the "bouba/kiki" effect
- Suspension spectrum functor
- Dative in front of accusative
- Dehn-twist on punctured 3-manifold
- Was Basilides's claim about crucifixion ever refuted?
- What are "rent and waistline parties"?
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
defaultTừ khóa » Html Col Center
-
Grid System - Bootstrap
-
How To Center A Column In Bootstrap - Tutorial Republic
-
HTML |
Align Attribute - GeeksforGeeks -
Bootstrap 4 Col Align Center Code Example
-
Bootstrap Col-md-6 Center Code Example
-
How To Center A Column In Bootstrap - Code Helpers
-
: The Table Column Element - HTML - MDN Web Docs - Mozilla -
CSS Utilities: Classes For Text/Element Alignment Or Modification
-
Layout And Grid System | Components | BootstrapVue
-
Bootstrap 4 Vertical Center. How To Vertically Align Anything - Medium
-
Center Bootstrap 4 Columns On Codeply
-
CSS Align-content Property - W3Schools
-
11 Ways To Center Div Or Text In Div In CSS - HubSpot Blog
-
How To Center In CSS With CSS Grid - Cory Rylan