This question already has answers here:
How can I horizontally center an element?
(133 answers)
Closed 4 months ago.
The CSS is below:
#RR .rewards-banner-lego .bubble ul {
align-items: center;
bottom: 100px;
column-count: 4;
display: flex;
justify-content: center;
list-style: none;
position: relative;
}
If I add something like width: 500px; it adjusts to the side and does not center, how come?
it could be that 500px is too small so another way to add the width is by putting width: 100%; making your ul the same width as the website (if that's what you're wanting). If it's still not centered then you might try justify-content: center; which makes all the items in the element go to the center of it horizontally.
Related
This question already has answers here:
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
Closed 1 year ago.
CSS Code:
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 400px;
}
.box1 {
background-color: aliceblue;
height: 70%;
width: 70%;
}
I tried vertical-align to center in box1 and nothing happened either. My box with the current code has vertically centered text but not horizontally. Any tips?
You can nest flex containers. This means your box can also have the display: flex; property, plus justify-content: center; for horizontally centering. Also look into the "place-" property with which you can center things on both axes with one single line of CSS.
This question already has answers here:
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
How can I vertically center a div element for all browsers using CSS?
(48 answers)
Flexbox: center horizontally and vertically
(14 answers)
Closed 1 year ago.
I can get it to center vertically or horizontally but not both at the same time. This is the css code I have so far:
.my-flex{
display: flex;
height: 100%;
width: 100%
}
//other pieces of the the flexbox that i have before it that aren't relevent
.last-element{
flex-grow: 1 0 auto;
align-self: center;
justify-self:center;
}
I also tried having the my-flex also be jusify-content center and flex-start as well as align-items
.my-flex{
display: flex;
height: 100%;
width: 100%
}
//other pieces of the the flexbox that i have before it that aren't relevent
.last-element{
flex-grow: 1;
align-self: center;
justify-self:center;
text-align: center
}
This is what I got to work!
if <div class="my-flex"> is the parent div, then
.my-flex{
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
This question already has answers here:
Flexbox: center horizontally and vertically
(14 answers)
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
Closed 2 years ago.
I'm creating a simple footer and want all of the text in it to be vertically centered. I tried several things but none of this worked:
footer {
height: 50px;
width: 100%;
bottom: 0;
position: fixed;
background-color: lightgray;
flex: display;
flex-direction: column;
justify-content: center;
justify-items: center;
align-items: center;
align-content: center;
text-align: center;
color: blue;
}
The horizontal centering works great. What am I doing wrong with the vertical centering?
You have flex: display; it should be display: flex;
When you make this adjustment, you will see it works to your request.
This question already has answers here:
Why is setting the top-margin of this child element pushing its parent container down with it?
(4 answers)
How to Fix Collapsing Top and Bottom Margins?
(4 answers)
What is the point of CSS collapsing margins?
(1 answer)
Closed 4 years ago.
I set margin-top to the mail icon,but div moves too
I don't understand what is my mistake?
In html they are in the same class
image
div.support{
width: 100%;
background-color:$blood;
height: 15vh;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
div.container{/*It moves too*/
flex:1;
h1,span{
margin-top: 0;
margin-left: 5vw;
color:white;
}
}
div.iconicfill-mail:before{/*Mail icon */
display: inline-block;
margin-left:2vw;
font-size:40px;
margin-top: 3vh;
}
span{
margin-top: 15px;
}
This question already has answers here:
How to place two divs next to each other? [duplicate]
(13 answers)
Closed 5 years ago.
I need to align an element to the center of the screen while having an element to the left of it.
I can achieve this with float left and setting the padding of the center element to match the width of the floated element. But, in this case I will not always know the width.
I do not know how better to explain this. Searchs have failed me.
You can use css flex to get the same flex Guide
body,
html {
margin: 0;
padding: 0;
height: 100%;
}
.wrapper {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: center;
height: 100%;
}
.box-1 {
padding: 2%;
background: tomato;
flex: 0 0 10%;
}
<div class="wrapper">
<div class="box-1">1</div>
<div class="box-1">2</div>
</div>