Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to use .CSS file to make a sidebar

Status
Not open for further replies.

klear

Technical User
Mar 10, 2003
16
US
I am currently trying to make a CSS file that enables me to make a sidebar. What I want to do is to be able to make links and pictures on that sidebar. The Main Question is, would it be possible to make the pictures/links accessable through the .css file? I am a TOTAL NOOB with .css files and I can't make heads or tails of anything. Any help would be appreciated.
 
Yes..

The style sheet
Code:
#test {
    background: url( [i]image.jpg[/i] );
    height: 50px;
    width: 50px;
}
The HTML document
Code:
<div id="test">
   Text on Top of Image
</div>

M. Brooks
 
The Main Question is, would it be possible to make the pictures/links accessable through the .css file?
Erm yes and no. You don't seem to have fully grasped the purpose of CSS files - they describe how the information contained (usually) in a (X)HTML document should be displayed.

So if you have pictures and links in a particular part of your document, it's possible to use CSS to display that part as a sidebar. You can't make a self-contained CSS file containing the whole sidebar in a form that you can somehow plug in to your pages - you'll have to use something like Server Side Includes to include the (X)HTML portion, the CSS file only holds the styling.

Here's an example:
Code:
<html>
<head>
<title>Example</title>
</head>
<body>
<div id="sidebar">
Blah Blah Blah
</div>
<div id="content">
Yadda Yadda Yadda
</div>
</body>
</html>
That's just an HTML file with two blocks of content, there's nothing in there to say that one should be displayed down the side. We do that with CSS:
Code:
#sidebar {
   width: 10em;
   float: left;
}

#content {
   margin-left: 11em;
}
Here's a good site for further reading:
-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top