Jump to content

How to style a container in CSS

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 post
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 post
Share on other sites

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



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

Edited by CodeName
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...