Jump to content

Hey guys,

 

I have to make a simple website as an assignment, but I have an issue with getting the layout to what I want.

 

I want my site to have 2 columns (navigation on the left, content on the right). I found a css template from 

https://www.w3schools.com/css/tryit.asp?filename=trycss_layout_cols

that does this.

 

However, that setup stretches the page across the whole width of my screen. I've figured out how to set a fixed width for the columns, but now I cant figure out how to centre them on the screen.

Can any one help me please?

 

 

Link to comment
https://linustechtips.com/topic/1058106-htmlcss-layout-help/
Share on other sites

Link to post
Share on other sites

Just now, duncannah said:

Try `margin: auto` on the parent element. Seeing the source code would be helpful

the source code is the same as the one i linked, i just changed the widths to use absolute  values rather than %.

 

I have tried margin:auto on everything i could but it doesnt seem to work.

Link to comment
https://linustechtips.com/topic/1058106-htmlcss-layout-help/#findComment-12512829
Share on other sites

Link to post
Share on other sites

2 minutes ago, Ragingwasabi said:

the source code is the same as the one i linked, i just changed the widths to use absolute  values rather than %.

  

I have tried margin:auto on everything i could but it doesnt seem to work.

Looks like you also have to set the width as well.

.clearfix {
	width: 600px; /* width here */
	margin: auto;
}

image.png.c11a16b33702566a663d6b7893c11ac1.png

🙂

Link to comment
https://linustechtips.com/topic/1058106-htmlcss-layout-help/#findComment-12512836
Share on other sites

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

×