Jump to content

How to style a container in CSS


coolgirl1
 Share

Recommended Posts

Hi!to a previous post I had. I talked about having trouble centering a picture and being able to add links to the left of it because the links would be pushed down. I figured out that I need to do a container. Problem is, not sure how to style it in CSSI want my link menu to be to the left and I want my image to be centered. Do I have to do a complete HTML layout or can I just contain the image?How would I go about that code wise? I know in HTML I would put< div id="container"> or <div id="content">Any help would be appreciated. Thanks. :)

  • Like 1
Link to comment
Share on other sites

wrap menu links in container div, or use unordered list UL ,and float this container left. You now have 2 options, (1) Place image in a div container, and add styling text-align: center; and place this div container BELOW menu link container, because the menu container is floated left, the block element container div will merge with it and the image will be centred. (2) Make the image that is by default a inline element a block element by using display: block; make sure you have defined a width, and apply margin: 0 auto;, and place BELOW menu link container, again because it is now converted into a block element it will act as the block element container in option 1.

Link to comment
Share on other sites

Create containers (<div>s) float one left and the other one right (making it two <div>s).EX:CSS:

div#left{width:300px;height:600px;float:left;background:gray}div#right{width:900px;height:600px;float:right;background:red;text-align:center}

HTML:

<div id="left"></div><div id="right"><img src='image.gif'/></div>

Edited by CodeName
Link to comment
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
 Share

×
×
  • Create New...