CSS All Body Content Centered [duplicate] - css

This question already has answers here:
How to align entire html body to the center?
(11 answers)
Closed 6 years ago.
How to center all the HTML elements horizontally and vertically between the <body> </body> without updating the elements left: and top: property when the window gets resised.

.center { margin: auto auto 3px 3px; }
By using this in your internal or external CSS file all the text elements will be center aligned and there will be a margin of 3 pixels above and below the division.

Related

inline-block moving down on page [duplicate]

This question already has answers here:
Why is this inline-block element pushed downward?
(8 answers)
Missalignment with inline-block (other elements pushed down)
(2 answers)
CSS inline-block issue - element being pushed down [duplicate]
(3 answers)
Closed 3 months ago.
I am participating in a CSS class on Udemy. Unfortunately I got no answers on thier internal discord site, so I am trying here.
This is a question about the display of some elements. What I don't understand is that first div element is moving down on the page, because I wrote the text "Hey you" in it. It shouldn't move down in my opinion, it should stay on the top of the page inline with the other two elements.
Here is the html and CSS:
div {
height: 200px;
width: 200px;
background-color: olivedrab;
border: 5px solid black;
display: inline-block;
margin: 50px;
}
<div>Hey you</div>
<div></div>
<div></div>
First div moving down
I have tried to give the first div an id:
<div id="first_div">Hey you</div>
And give that id a position of absolute:
#first_div {
position: absolute;
}
But it doesn't really work since the absolute value of the position property removes the element from the document flow, and thereby places it on top of the second element, so only two out of the three divs is showing, so no fix really!
Divs are now incorrectly stacked

How to centralize text vertically and horizontally in the square [duplicate]

This question already has answers here:
How can I center text (horizontally and vertically) inside a div block?
(27 answers)
Flexbox: center horizontally and vertically
(14 answers)
Closed 2 years ago.
I used some boxes in the website below with the title Products.I want to text vertically and horizontally be in the center in the boxes (Square).Already tried:
display:table-cell;
vertical-align: middle;
but nothing happens at all. what should i do?
website: http://www.titanotrade.com.tr/
Use the line-height property to adjust the position of the text in your boxes e.g.
.title-product a {
line-height: 270px;
}

Flex box fit width with it's childs when child is out of window? [duplicate]

This question already has answers here:
When flexbox items wrap in column mode, container does not grow its width
(9 answers)
Closed 4 years ago.
I'm using a column wrap layout, and the page is going to load new content and append them as new children elements to the parent box element, so I hope the box width auto fit to the children elements.
Codes here: https://codepen.io/mashirozx/pen/exgRqV
What it looks now:
My hope (Notice the overflow-x bar):
Problem solved:
Adding overflow: auto to the flex box.
Try to change:
flex-container-content > div {
background-color: #EB213C;
width: auto;
margin: 10px;
text-align: center;
line-height: 75px;
font-size: 30px;`

CSS ul li height does not cover the content [duplicate]

This question already has answers here:
Floated element gets outside of its parent?
(5 answers)
Closed 6 years ago.
The li height is not defined and it automatically changes with the content. However, it only changes with the right hand side of its content rather than the left. Have changed the left side to block but it does not work. The link is as follows:
[http://ec2-52-32-145-125.us-west-2.compute.amazonaws.com/#/posts][1]
Add this to your CSS:
.posts li {
overflow: auto;
}

What ways of vertical text centering inside a div contaner do you know? [duplicate]

This question already has answers here:
How do I vertically center text with CSS? [duplicate]
(37 answers)
Closed 8 years ago.
What ways of vertical text centering inside a div contaner do you know?
text-align:center;
margin:0 auto; //tag needs to have a with
If a single line of text, setting the line height of the div to be the height of the div.
If the height of the content is known, position it absolutely - top: 50%, margin-top: -(half the height of the content) pixels.

Resources