Jump to content

Aligning entire row/span as center HTML/CSS

image.thumb.png.821c75aa4571df8167064f7bafbc5eb1.png

 

Basically trying to center a 3x3 grid into the center of the page but can't get it to align on the center, how does one go about that? 

 

I tried using display: block in a css class "top-images" that's on all the spans but ends up turning all the photos into a div layout

Current system - ThinkPad Yoga 460

ExSystems

Spoiler

Laptop - ASUS FX503VD

|| Case: NZXT H440 ❤️|| MB: Gigabyte GA-Z170XP-SLI || CPU: Skylake Chip || Graphics card : GTX 970 Strix || RAM: Crucial Ballistix 16GB || Storage:1TB WD+500GB WD + 120Gb HyperX savage|| Monitor: Dell U2412M+LG 24MP55HQ+Philips TV ||  PSU CX600M || 

 

Link to comment
https://linustechtips.com/topic/1402612-aligning-entire-rowspan-as-center-htmlcss/
Share on other sites

Link to post
Share on other sites

Apply auto margins

.content-section div {
    width: 80%;
    margin-left: auto; # auto margins to center content within parent element
    margin-right: auto;
}

 

Or the modern way of displaying content within a grid is flex box

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

 

Link to post
Share on other sites

The simplest way to do this is to wrap the grid in a container (or using your .content-section element if you want to centre the text in it too) and setting `text-align: center` on the container.

This works because images are part of the phrasing content by default, so they're influenced by the text alignment

🙂

Link to post
Share on other sites

5 hours ago, C2dan88 said:

Apply auto margins

.content-section div {
    width: 80%;
    margin-left: auto; # auto margins to center content within parent element
    margin-right: auto;
}

 

Or the modern way of displaying content within a grid is flex box

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

 

 

58 minutes ago, duncannah said:

The simplest way to do this is to wrap the grid in a container (or using your .content-section element if you want to centre the text in it too) and setting `text-align: center` on the container.

This works because images are part of the phrasing content by default, so they're influenced by the text alignment

 

A combination of you both and that really informative flex website helped!

Thank you! 

 

Taking a web dev course in school this semester and looking forward to it

Current system - ThinkPad Yoga 460

ExSystems

Spoiler

Laptop - ASUS FX503VD

|| Case: NZXT H440 ❤️|| MB: Gigabyte GA-Z170XP-SLI || CPU: Skylake Chip || Graphics card : GTX 970 Strix || RAM: Crucial Ballistix 16GB || Storage:1TB WD+500GB WD + 120Gb HyperX savage|| Monitor: Dell U2412M+LG 24MP55HQ+Philips TV ||  PSU CX600M || 

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×