Elements inside the row to be center aligned - css

I want is that these circles to be center aligned , I tried using some display inline block but no affect on it and some other properties that make center align but i failed picture of those circles
I am searching for this already the whole day :s
How can help me on this one?
Your help would be much appreciated.
Thank you
.menu{
width:70px;
height:70px;
border-radius:50px;
font-size:20px;
color:green;
line-height:100px;
background:#32C947;
overflow: hidden;
list-style-type: none;
margin-left: auto;
margin-right: auto;
display: table-cell;
vertical-align: middle;
}
.menu:hover{
color:#ccc;
text-decoration:none;
background:#333
}
<div class = "container">
<div class="row ">
<div class="col-md-12 ">
<h1 class = "_font ">All Plans Include</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Hello</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 ">
<h1 class="_circle">Google Analytic</h1>
</div>
</div>
</div>

To the parent div of a circle you have to give some width property and use
this and margin: 0 auto;. I hope this will works.
In your code parent div .col-md-1 .so you have to create one more div and
apply above property.
<div class="col-md-1 ">
<div class="circle_menu">
</div>
<h1 class="_circle">Google Analytic</h1>
</div>

.menu{
width:70px;
height:70px;
border-radius:50px;
font-size:20px;
color:green;
line-height:100px;
background:#32C947;
display: block;
overflow: hidden;
list-style-type: none;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
}
.center{
text-align: center;
}
.menu:hover{
color:#ccc;
text-decoration:none;
background:#333
}
<div class = "container">
<div class="row justify-content-center">
<div class="col-md-12 center">
<h1 class = "_font ">All Plans Include</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Hello</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
<div class="col-md-1 center">
<h1 class="_circle">Google Analytic</h1>
</div>
</div>
</div>

The col-md-1 class is probably from bootstrap and therefor floating to the left. You could add the col-md-offset class to push the menu items to the center.

There are several ways to center align that block. But since you use the Bootstrap it will be best to use the in build display:block property of a center-block class.
Set an element to display: block and center via margin. Available as a
mixin and class.
Read More from Here Bootstrap Documentation About centering a Class
You can do either any one of this
<div class = "container center-block">
<div class="row ">
CODE SNIPPPET
</div>
</div>
OR
<div class = "container">
<div class="row center-block">
CODE SNIPPPET
</div>
</div>
The center-block class which we add overrides the display:block put in by using the regular container or row class
Hope This helped. Happy Coding. :)

Do you have Bootstrap actually linked to your code? I just put it into a CodePen
and linked Bootstrap3 and it formatted correctly as you want (except the text is to big). I took out these lines from your .menu class as well:
vertical-align: middle;
list-style-type: none;
margin-left: auto;
margin-right: auto;
Edit:
So the reason why your circles are not centered is because you are using Bootstrap's grid system. The grid is sliced into 12 different sections and you have 8 of the sections filled with elements (and 12 isn't divided by 8 evenly). That means that there are 4 spaces not being used to the right of your circles.
To fix this, I added two empty div tags before all of the elements you have implemented like so:
<div class="col-md-1"></div>
This makes it so that there are two empty grid slots before your circles (to the left) and two after (to the right). Here is the Updated CodePen for you to look at.
Note: I added this style for you to center your text through CSS:
div.row {
text-align: center;
}

Related

Center container in html [duplicate]

This question already has answers here:
How can I horizontally center an element?
(133 answers)
Closed 20 days ago.
Does anyone know how to center my container to be center. I try to align my code to be center but it doesn't apply the code. I try to change it but it doesnt work. Do I miss something? It show like this.
I want it to be center but it doesnt work. Here is my html code.
<div class="row">
<div class="col-md-8" style="margin-top: 30px;">
<div class="card" style="font-size: 100px; text-align: center; height: 100px;">
<div class="card-body">
</div>
<div class="card-footer">
<div class="row">
<div class="col-md-12">
Update:
I edited your code to a static html to test it out.
I can see that your code is working, but you can try to add text-align: center; in order to make everything in the container centered.
Below is the full code, and you can test it here too: https://codesandbox.io/s/festive-hopper-73v528?file=/index.html
and here's a live preview: https://73v528.csb.app/
<div
class="container"
style="margin-top: 50px; margin-bottom: 50px; text-align: center;"
>
<div class="row">
<div class="col-md-4">
<h1>My Uploads</h1>
</div>
<div class="col-md-4">
<a
href="javascript:void(0);"
class="btn btn-primary"
onclick="selectFileForUpload();"
>Upload</a
>
</div>
</div>
<div class="row">
<div class="col-md-8" style="margin-top: 30px;">
<div
class="card"
style="font-size: 100px; text-align: center; height: 100px;"
>
<div class="card-body"></div>
<div class="card-footer">
<div class="row">
<div class="col-md-12">
<p>chap5</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
You have applied text-center property on body, but according to screenshot data is on footer
<div class="card" style="font-size: 100px; text-align: center; height: 100px;">
<div class="card-body">
</div>
<div class="card-footer">
<div class="row">
<div class="col-md-12">
instead apply style on <div class="card"> check the snippet above

How to make bootstrap loader lay on div?

im so clueless in css,I have a loader,when i click the function it just starts below the image ina div which is so ugly,i want it to come over, it any idea?
<div class="card" (click)="SendToBank($event)">
<div class="k-block" *ngIf="loadingSpinner">
<div class="spinner-border text-info" role="status" >
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="card-body">
<img class="bank-logo" src="../assets/Img/2.png" id="seb">
<span> SEB</span>
</div>
</div>
any idea how i can achieve that?
Well you just need to position it fixed and style it a little bit.
Read more here css position
I left out the Angular related code.
.k-block {
position:fixed;
display:flex;
width: 100%;
height: 100%;
left:0;
top:0;
align-items: center;
justify-content: center;
background: rgba(0,0,0,0.5)
}
<div class="card">
<div class="k-block">
<div class="spinner-border text-info" role="status">
<span class="sr-only">Loading...</span>
</div>
</div>
<div class="card-body">
<img class="bank-logo" src="../assets/Img/2.png" id="seb">
<span> SEB</span>
</div>
</div>

CSS how to align different size images with text inside row?

Need to align four different height (beetween 160-180px) svg images with text under them.
Images should be placed in line at sight and I don't know how to make strict align short text under them in one line like on screenshot.
Thanks!
UPD: Sorry for inconvinient information, thought that this question is quite typical for those who know css good.
Here is my html and css. Also I'm using bootstrap rows.
<div class="did-you-know">
<div class="row items">
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-wa.svg"/>
</div>
<div class="title text-poppins">
<p>We’re from WA</p>
<p>{like you!}</p>
</div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-packaging.svg"/>
</div>
<div class="title text-poppins">
<p>We use minimal packaging</p>
<p>{great for the planet}</p></div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-quality.svg"/>
</div>
<div class="title text-poppins">
<p>We only choose quality</p>
<p>{better for your health}</p></div>
</div>
<div class="col-lg-3 col-xs-6">
<div class="icon">
<img src="/img/mswa/inline-community.svg"/>
</div>
<div class="title text-poppins">
<p>We love giving back</p>
<p>{great for our community}</p></div>
</div>
</div>
</div>
.did-you-know {
padding: 20px;
text-align: center;
}
.did-you-know .items .icon {
padding: 50px;
}
.did-you-know .items .title {
font-size: 20px;
}
here is a solution:
Replace images by your images.
<!DOCTYPE html>
<html>
<head>
<style>
* {
box-sizing: border-box;
}
.column {
float: left;
width: 25%;
padding: 5px;
}
/* Clearfix (clear floats) */
.row::after {
content: "";
clear: both;
display: table;
}
</style>
</head>
<body>
<div class="row">
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Snow" style="width:100%">
<p style='text-align: center;'>test1</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Forest" style="width:100%">
<p style='text-align: center;'>test2</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Mountains" style="width:100%">
<p style='text-align: center;'>test3</p>
</div>
<div class="column">
<img src="https://freesvg.org/img/cartoonsun.png" alt="Mountains" style="width:100%">
<p style='text-align: center;'>test3</p>
</div>
</div>
</body>
</html>

Bootstrap 4 Vertically align footer while respecting columns and rows

I'm trying to find a solution how to vertically align the 2 rows in the footer which are placed with a Bootstrap grid.
I've already tried to make a wrapper for the content and apply the regular flexbox solution:
display: flex; align-items: center. But this moves both rows to be on the same row.
Fiddle here https://codepen.io/pen/WNNPdxv
HTML
<footer class="footer">
<div class="footer-wrapper">
<div class="container">
<div class="row row">
<div class="col-sm-8 footer-credit">
<h6>GetMove</h6>
<p>Copyright &copy 2019 GetMove All Rights Reserved</p>
</div>
<div class="col-sm-2 footer-contact">
<h6>Contact</h6>
hola#getmove.net
</div>
<div class="col-sm-2 footer-social-icons">
<h6>Follow us</h6>
<a class="social-icon" target="_blank" href="https://www.facebook.com/pg/GetMove.Official/"
><i class="fab fa-facebook-square"></i
></a>
<a class="social-icon" target="_blank" href="https://www.instagram.com/getmovemx/"
><i class="fab fa-instagram"></i
></a>
<a class="social-icon" target="_blank" href="https://soundcloud.com/getmove"
><i class="fab fa-soundcloud"></i
></a>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-8 text-center"></div>
<div class="col-sm-4 footer-newsletter">
<h6>Subscribe</h6>
<div class="input-group input-group-sm mb-3">
<input
type="text"
class="form-control shadow-none"
id="subscribe"
placeholder="# Enter your email adress"
aria-label="Sizing example input"
aria-describedby="inputGroup-sizing-sm"
/>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="button-addon1">
Submit
</button>
</div>
</div>
</div>
</div>
</div>
<div class="container footer-credit">
<div class="row">
<div class="col-sm-8"></div>
<div class="col-sm-4 footer-credit"></div>
</div>
</div>
</div>
</footer>
CSS
.footer {
width: 100%;
height: 24em; /* Set the fixed height of the footer here */
background-color: #f4f2f0;
margin-top: 4em;
}
.footer-social-icons {
list-style-type: none;
}
.footer h6 {
text-transform: uppercase;
font-size: 16px;
}
.footer-credit {
font-size: 11px;
}
.social-icon {
/* display: block; */
margin: 0;
font-size: 16px;
}
.form-control:focus {
border-color: black;
}
The idea of a wrapper to vertically center content is correct, however you already have a wrapper in place => container.
No need to have multiple containers inside a single section (footer). You use rows for this.
So to clean-up your structure a bit, as suggested in the comments, is key to understand what's going on.
container is your wrapper
row row is redundant
empty columns as placeholder are not required with flexbox (bootstrap 4), not sure if that's what's going on... => m-auto, ml-auto, mr-auto
place custom classes inside columns (these blocks might change places someday, especially when designing for a CMS)
keep the structure clean and decorate with utility classes if needed (padding, margin, ...)
HTML Structure
<footer role="contentinfo">
<div class="container">
<div class="row">
<div class="col-sm-7"></div>
<div class="col-sm-3"></div>
<div class="col-sm-2"></div>
</div>
<div class="row">
<div class="col-sm-5 ml-auto"></div>
</div>
<div class="row">
<div class="col-sm-5 ml-auto"></div>
</div>
</div>
</footer>
Solution
Now your height is set on the footer, your container is simply taking the required height inside the space. This means you should now be able to move it vertically with flexbox.
footer[role="contentinfo"] {
display: flex;
flex-flow: column wrap;
justify-content: center; /* content of the footer is the container */
}
DEMO

bootstrap CSS: center any col- that overflows a line

As can be seen in this fiddle, I have series of columns that are nested in a single row and designed to overflow onto as many new lines as necessary.
Since each col-* has the property align: left; from Bootstrap, cols that overflow onto a new line stay left aligned.
Visually, I'd like to have "incomplete" lines have divs that are centered, like this fiddle. But, these col- divs are created dynamically, so I can't just use offsets or additional rows to fix.
Any ideas on how to accomplish this? Thanks in advance.
Very easy. First, you change your HTML and add some special class just to make sure you don't affect the columns in other places of your layout. Since you have app-style, let's use that for the row, and let's add the myCentre class name to the xs-4 columns. Like this:
<div class="row app-style">
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>1</p>
</div>
</div>
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>2</p>
</div>
</div>
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>3</p>
</div>
</div>
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>4</p>
</div>
</div>
</div>
<div class="row app-style">
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>1</p>
</div>
</div>
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>2</p>
</div>
</div>
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>3</p>
</div>
</div>
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>4</p>
</div>
</div>
<div class="col-xs-4 myCentre">
<div class="box-btn-reports">
<p>Another col just because I can</p>
</div>
</div>
</div>
Now, we can use some extremely simple CSS. Basically, we're removing Bootstrap styles to use old school responsive approach: text-align:center for container, text-align:left for item elements, nothing new:
.app-style{text-align:center;}
.myCentre{display:inline-block;
float:none;
text-align:left;
margin-right:-4px;
vertical-align:top;}
.box-btn-reports {
text-align: center;
width: 100%;
margin-top: .5em;
margin-bottom: .5em;
border: 1px solid #888888;
border-radius: 8px;}
p {
padding: .1em;
font-size: 1.25em;
line-height: 150%;
}
and now you can [see the fiddle here] and how those columns are happily centered1

Resources