TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-08-2007, 06:56 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default CSS problem

Hi!
I've recently made a content box in photoshop, and since I've got nearly no knowledge in CSS, I would love to know how I would code this box in CSS.

HTML Code:
<div class="contentbox">

	<div class="head">
		<div id="title">New style</div>
	</div>
	
</div>
I want that, to generate this:



HTML Code:
	<div class="spacer"></div>


HTML Code:
	<div class="content">
		
		<div class="top">
		
			<div id="title">New style</div>
			<div id="admin">Edit   Delete</div>
			<div id="line"></div>
			<div id="postdetails">Posted 18:28 the 8th of December 2007 by Tanax</div>
			
		</div>
		
		<div class="content">
		
			<div id="post">Been working on a new style for the website today, and I think that I've finally came up with a nice design. Please tell me what you think of it!</div>
			
		</div>
		
		<div class="bottom">
			
			<div id="edited">Updated 18:39 the 8th of December by Friiidiiish</div>
			<div id="reason">Spelling mistake :P</div>
			<div id="line"></div>
			<div id="comments">Comments (13)</div>
			
		</div>


HTML Code:
	<div class="spacer"></div>
	
	<div class="footer"></div>




And so, the whole code would be:
HTML Code:
<div class="contentbox">

	<div class="header">
		<div id="title">New style</div>
	</div>
	
	<div class="spacer"></div>
	
	<div class="content">
		
		<div class="top">
		
			<div id="title">New style</div>
			<div id="admin">Edit   Delete</div>
			<div id="line"></div>
			<div id="postdetails">Posted 18:28 the 8th of December 2007 by Tanax</div>
			
		</div>
		
		<div class="content">
		
			<div id="post">Been working on a new style for the website today, and I think that I've finally came up with a nice design. Please tell me what you think of it!</div>
			
		</div>
		
		<div class="bottom">
			
			<div id="edited">Updated 18:39 the 8th of December by Friiidiiish</div>
			<div id="reason">Spelling mistake :P</div>
			<div id="line"></div>
			<div id="comments">Comments (13)</div>
			
		</div>
		
	</div>
	
	<div class="spacer"></div>
	
	<div class="footer"></div>
	
</div>


That's the structure of the HTML that I've thought out.. but I have no idea how to actually code it in CSS so the box expands if you write more text, etc etc..


Anyone have any ideas?

Oh, and I know that the quality is really bad.. it wasn't intentionally, but now after I've uploaded them, I realized that it was a kind of good way to prevent ppl from stealing it xD

This is not sliced yet btw..
Tanax is offline  
Reply With Quote
Old 12-08-2007, 07:30 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

This will give you the perfect layout, without the images. You can learn CSS by dropping in all the images and polishing it off ! Try W3Schools.com.

html4strict Code:
<style type="text/css">

    body
    {
        text-align: center;
    }
   
    div.header
    {
        background-color: rgb(150, 150, 150);
        margin: auto;
        width: 800px;
    }
   
    div.content
    {
        margin: 20px auto auto auto;
        width: 750px;
        text-align: left;
        overflow: hidden;
    }
   
    div.content div.top
    {
        border-bottom: 1px solid rgb(45, 45, 45);
        overflow: hidden;
        float: left;
    }
   
    div.content div#postdetails
    {
        clear: both;
        padding-top: 5px;
    }
   
    div.content div.top div#title
    {
        float: left;
        overflow: hidden;
        font-family: Georgia;
        font-size: 24px;
    }
   
    div.content div.admin
    {
        float: right;
        overflow: hidden;
    }
   
    div.content div.contentbody
    {
        overflow: hidden;
        margin-top: 20px;
       
        /* Won't work in IE but why do you want so much empty space anyway? */
        min-height: 100px;
    }
   
    div.bottom
    {
        overflow: hidden;
        float: left;
        border-bottom: 1px solid rgb(45, 45, 45);
    }
   
    div.bottom div#edited
    {
        float: left;
        overflow: hidden;
    }
   
    div.bottom div#reason
    {
        padding-left: 5px;
        float: left;
        overflow: hidden;
    }
   
    div#comments
    {
        clear: both;
        width: 750px;
        margin: auto;
        overflow: hidden;
        text-align: left;
        padding: 15px 0 15px 0;
    }
   
    div.footer
    {
        background-color: rgb(150, 150, 150);
        height: 15px;
        width: 800px;
        margin: auto;
    }

</style>

<body>
<div class="contentbox">

    <div class="header">
        <div id="title">New style</div>
    </div>
   
    <div class="content">
       
        <div class="top">
            <div id="title">New style</div>
            <div class="admin">Edit   Delete</div>
        </div>
       
        <div id="postdetails">Posted 18:28 the 8th of December 2007 by Tanax</div>
       
        <div class="contentbody">
       
            <div id="post">Been working on a new style for the website today, and I think that I've finally came up with a nice design. Please tell me what you think of it!</div>
           
        </div>
       
        <div class="bottom">
           
            <div id="edited">Updated 18:39 the 8th of December by Friiidiiish</div>
            <div id="reason">Spelling mistake :P</div>
            <div class="admin">Edit   Delete</div>
           
        </div>
       
    </div>
   
    <div id="comments">Comments (13)</div>
   
    <div class="footer"></div>
   
</div>
</body>
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
Tanax (12-08-2007)
Old 12-08-2007, 08:11 PM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Thanks! That's really neat :D

Now I just have to figure out how to get the images.. >.<
Tanax is offline  
Reply With Quote
Old 12-08-2007, 08:35 PM   #4 (permalink)
The Wanderer
 
victorius's Avatar
 
Join Date: Nov 2007
Location: Denmark
Posts: 21
Thanks: 4
victorius is on a distinguished road
Default Here's a quick try

Hi Tanax, here is my ~20min take on this. I actually sliced your graphics so I could use them.

See the attachment from me with the HTML (styles in the html) and two graphics files. These are ofcourse just in the jpeg quality you posted here earlier.

But I made it so that each post can expand at will, and the heading will remain in the middle but the lower bars will extend from the center. (change the width of the container to try out)

Ah, one more thing, the pictures are transparent png's. Which means that you can change the background and the bar will blend in. This will not work in IE6 though unless you use a png fix for IE6
Attached Thumbnails
css-problem-tanax-black.jpg  css-problem-tanax-red.jpg  
Attached Files
File Type: zip tanax-css.zip (10.2 KB, 15 views)
Send a message via MSN to victorius
victorius is offline  
Reply With Quote
The Following User Says Thank You to victorius For This Useful Post:
Tanax (12-08-2007)
Old 12-08-2007, 08:58 PM   #5 (permalink)
The Wanderer
 
victorius's Avatar
 
Join Date: Nov 2007
Location: Denmark
Posts: 21
Thanks: 4
victorius is on a distinguished road
Default ah, beaten to the punch

Oh, Wildhoney you were quicker than me.

Although probably great solution you've come up with there, it's my personal opinion that we don't need to use so many divs. (Tanax as well)

Also, using the id="" so much makes it (according to standards) impossible to have more than one of those blocks in the same document. The id is supposed to be unique in a document.

Although it will display correctly, the best practice is to only assign id to a specific item.

And this block you can repeat as you like for many posts.

Oh, and yet another thing. It's important for SEO to use headings

Here is a sample from my proposal. I use the standard tags as much as possible. Even in this case I would probably try to use less code, but I was trying to make it look exactly like Tanax's mockup.
Code:
<!-- A single post -->          
            <div class="post">            
                
                <!-- The title bar with graphics -->
                <div class="post-title"><p>New style</p></div>
                
                <!-- actual post contents -->
                <div class="post-content">
                    <!-- the admin panel -->                
                    <div class="admin-panel"><a href="#">Edit</a> <a href="#">Delete</a></div>                           
                    
                    <!-- Title: always use a heading tag as a title -->
                    <h2>New style</h2>
                    
                    <p>Been working on a new style for the website today, and I think that I've finally came up with a nice design. Please tell me what you think of it!</p>
                    
                    <p>Been working on a new style for the website today, and I think that I've finally came up with a nice design. Please tell me what you think of it!</p>
                    
                    <div class="admin-panel"><a href="#">Edit</a> <a href="#">Delete</a></div>
                                        
                    <p class="post-details">Updated 18:39 the 8th of December by <a href="#">Friiidiiish</a></p>
                    <p class="comments"><a href="#">Comments (13)</a></p>
                </div>
            </div>
        <!-- A single post -->
See the attached file for the whole thing.
Send a message via MSN to victorius
victorius is offline  
Reply With Quote
Old 12-08-2007, 10:11 PM   #6 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

That's awesome :| :O

A big thanks to you! I will study the code carefully :D

One thing though that got my attention.. I'm trying to slice my own pictures.. so I get full quality.. but the header turns out to be a real pain in the ass to get working >.<

Because the left and the right sides of the header(and the footer), is rounded... so I'm using another image there.

For the footer I've just used:
HTML Code:
            div.footer {
        		background: url(footer.jpg) repeat-x top left;
        		height: 15px;
        		margin: auto;
    		}

                <div class="footer">
                	<img src="footer-left.jpg" style="float: left;" />
					<img src="footer-right.jpg" style="float: right;" />
                </div>
But that doesn't work for the header =//
See SS
Attached Thumbnails
css-problem-uhm.jpg  
Tanax is offline  
Reply With Quote
Old 12-08-2007, 10:55 PM   #7 (permalink)
The Wanderer
 
victorius's Avatar
 
Join Date: Nov 2007
Location: Denmark
Posts: 21
Thanks: 4
victorius is on a distinguished road
Default

Oh, I didn't notice they were round.

Judging by the top left corner of the first post in your screenshot, the round image isn't aligning with the header.

There are a few possible solutions to that
  1. The image isn't the same height as the header image. You need to add transp. pixels above so it is the same height.
  2. use padding-top on the image to make it fit

Also, I noticed that in your (original) version the lines underneath the title and above the comments don't go all the way across like they do in my version. So if you want that back with my code, then...
  1. change in .post h2
    padding to margin of the same value
  2. .comments {
    In here this is inherited from the P tag, so you will have to set padding to 0 and margin to the same as in the previous example.
Send a message via MSN to victorius
victorius is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 07:01 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design