Jump to content
coolgirl1

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

Share this post


Link to post
Share on other sites

If your div has a width, all you need is margin: 0 auto;

Share this post


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.

Share this post


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#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

Share this post


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.

Guest
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.

Loading...

×
×
  • Create New...